Skip to content
Prev 4466 / 63421 Next

works in R-1.1.1 but not in R-development; why?

On Thu, 12 Oct 2000, Ramon Diaz-Uriarte wrote:

            
There's something tricky happening with parent.frame()

lapply(1:10,function(x,y) {browser();x+y),y=1)

Browse[1]> eval(quote(parent.frame()),parent.frame())
<environment: 1004cb70>
Browse[1]> eval(quote(sys.frame(sys.parent())),parent.frame())
<environment: 1004cdc88>

so parent.frame() isn't an exact synonym for sys.frame(sys.parent()). I
think this i


There *has* also been a change in the scoping rules (only partly
deliberate) in model.frame as Peter pointed out, though I don't think it
is applying here. A formula now has an environment associated with it,
which is used as the default environment for variables not specified in
data=

If you do
  lapply(datai,function(w) model.frame(~w))
it works: the vector w is found in the environment of the anonymous
function.
If you do
  ff<- ~w
  lapply(datai,function(w) model.frame(ff))
it doesn't work, since the default environment is now the global one.

	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle
Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._