[R] do.call environment misunderstanding

Dan Murphy chiefmurphy at gmail.com
Tue Jun 25 15:32:31 CEST 2013


I am having difficulty understanding the envir argument of do.call.
The help page says

envir  an environment within which to evaluate the call.

so I thought that in the following toy example x would be found in the
environment e and f would return 4 via do.call:

> e <- new.env()
> e$x <- 2
> f <- function() x^2
> do.call(f, list(), envir = e)
Error in (function ()  : object 'x' not found

Thanks in advance for clarifying my misunderstanding.

Dan Murphy



More information about the R-help mailing list