[R] Global variables
abhagwat
bhagwataditya at gmail.com
Mon May 2 13:19:10 CEST 2011
Well, what would be really helpful is to restrict the scope of all
non-function variables, but keep a global for scope of all function
variables. Then, you still have access to all loaded functions, but you
don't mix up variables.
How would one do that?
Adi
> Is there a way I can prevent global variables to be visible within my
> functions?
Yes, but you probably shouldn't. You would do it by setting the
environment of the function to something that doesn't have the global
environment as a parent, or grandparent, etc. The only common examples
of that are baseenv() and emptyenv(). For example,
x <- 1
f <- function() print(x)
--
View this message in context: http://r.789695.n4.nabble.com/Global-variables-tp3178242p3489796.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list