[R] environments
Antje
niederlein-rstat at yahoo.de
Tue Aug 26 11:02:10 CEST 2008
Hi there,
I try to understand the usage of environments but I'm not sure if I get it. I
wrote a test script like this:
testenv <- new.env(environment())
myfun <- function(x) {
print(testvar)
testenv$testvar_2 <- 20
}
environment(myfun) <- testenv
testenv$testvar <- 10
myfun("hello")
ls(envir = testenv)
Now, I was wondering if there is any way to create new variables in my
environment without this "testenv$...". I know that I can access it that way if
I do an attach(testenv) before, but that does not help when creating new ones...
Do I completely misunderstand the concept?
I'm just looking for an elegant way to access objects of a graphical
userinterface from each handler-function and so on. And I thought it might be
good to pack them into an environment...
Antje
More information about the R-help
mailing list