Re: [R] do.call environment misunderstanding

2013-06-25 Thread David Winsemius
On Jun 25, 2013, at 6:05 PM, Dan Murphy wrote: > My problem is to evaluate a function/model whose definition and > parameters (I'll put x into the arguments) and other data are saved by > someone else in an Rdata file, but I don't know the function name, > definition or data. Nevertheless, I need

Re: [R] do.call environment misunderstanding

2013-06-25 Thread Dan Murphy
My problem is to evaluate a function/model whose definition and parameters (I'll put x into the arguments) and other data are saved by someone else in an Rdata file, but I don't know the function name, definition or data. Nevertheless, I need to save whatever functional values/model solutions are s

Re: [R] do.call environment misunderstanding

2013-06-25 Thread Duncan Murdoch
On 25/06/2013 11:56 AM, Dan Murphy wrote: So the trick is to put the function f into e and define its environment to be e: Putting f into e, and defining the environment of f to be e solve different problems. Your toy example has both problems so it's a reasonable solution there, but most re

Re: [R] do.call environment misunderstanding

2013-06-25 Thread Dan Murphy
So the trick is to put the function f into e and define its environment to be e: > e <- new.env() > e$f <- function() x^2 > environment(e$f) <- e > e$x <- 2 > do.call("f", list(), envir = e) [1] 4 Thanks, Duncan. On Tue, Jun 25, 2013 at 6:49 AM, Duncan Murdoch wrote: > On 25/06/2013 9:32 AM, Dan

Re: [R] do.call environment misunderstanding

2013-06-25 Thread Duncan Murdoch
On 25/06/2013 9:32 AM, Dan Murphy wrote: 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

[R] do.call environment misunderstanding

2013-06-25 Thread Dan Murphy
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 <