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

______________________________________________
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