On 12-04-04 4:52 PM, Sam Steingold wrote:
Since R has the same namespace for functions and variables,
c<- 1
kills the global function, which can be restored by
c<- get("c",mode="function")

Is there a way to prevent R from overriding globals
or at least warning when I do that
or at least warning when I replace a functional value with non-functional?

It doesn't kill it, it just hides it. You can still get the original by telling R which one you want, e.g. base::c.

You'll get a warning when you do this in a package, e.g. library(Hmisc) will tell you that it has hidden 5 functions from view.

There's no warning when you mask a function with a non-function at top level, and little need for one, because R does the right search based on the fact that you're making a function call:

> c
[1] 1
> c(1,2)
[1] 1 2

It only matters when you need to pass the function as an argument, e.g. to one of the apply() family of functions.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to