Displaying 1 result from an estimated 1 matches for "2007720".
Did you mean:
20070720
2006 Apr 04
2
Return function from function with minimal environment
...n(huge);
env <- new.env();
assign("scale", scale, envir=env);
bar <- function(x) { scale * x };
environment(bar) <- env;
bar;
}
fcn <- foo3(1:10e5)
But,
env <- environment(fcn)
save(env, file="temp.RData");
file.info("temp.RData")$size
# [1] 2007720
When I try to set the parent environment of 'env' to emptyenv(), it
does not work, e.g.
fcn(2)
# Error in fcn(2) : attempt to apply non-function
but with the new.env(parent=baseenv()) it works fine. The "base"
environment has the empty environment as a parent. So, I try to do...