[R] assign / environment side effect on R 2.4.0

Thomas Petzoldt thpe at hhbio.wasser.tu-dresden.de
Fri Jun 23 17:35:42 CEST 2006


the posted example had the side effect on all platforms (correctly: R
2.2.1/Windows, 2.3.1/Linux, 2.4.0/Windows), but in the following
corrected example the behavior of 2.4.0 differs from the older versions.

The only difference between the "wrong" and the "new" example is
L[["test"]] vs. L$test in the assign.

Thomas P.

envfun <- function(L) {
#  L <- as.list(unlist(L))
  p <- parent.frame()
  assign("test", L[["test"]], p) ## [["test"]] instead of $test
  environment(p[["test"]]) <- p

solver <- function(L) {
  # some other stuff

L <- list(test = function() 1 + 2)

e1 <- environment(L$test)
e2 <- environment(L$test)


More information about the R-help mailing list