I did something silly in an R session. I wrote
print = FALSE
Now I can’t print things!
[1] FALSE
How do I get it back?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The irony here is that you did NOT overwrite it. You created a data object named “print” and when you typed
printat the console, the eval-print loop took over and returned it. Had you tested for the behavior of print correctly by typingprint("something")orprint(42)you would have seen that the interpreter was still able to find theprint.defaultfunction in the base NAMESPACE. Defining data objects with the same names as existing functions is bad practice, not because they overwrite in the R interpreter, but because they overwrite in minds of users. The interpreter determines your intent (well, it determines what it will do anyway) by seeing whether there is a open-parenthesis which signifies a function call. If the letters p-r-i-n-t are followed by “(” then the interpreter looks at the class of the argument and dispatches the appropriate print method.