On 27/03/2014, 7:38 PM, Thomas Lumley wrote:
You get what you wanted from

do.call(plot,list(x=quote(x),y=quote(y)))

By the time do.call() gets the arguments it doesn't know how y was
originally computed, just what values it has.

This works, but it doesn't make sense to me. The arguments end up with the expressions x and y, but why are they evaluated in the right place? Quote doesn't bind an environment to its expressions, does it? How does plot() know where to evaluate them?

Duncan Murdoch



    -thomas


On Thu, Mar 27, 2014 at 6:17 PM, Rolf Turner <r.tur...@auckland.ac.nz>wrote:



I was under the impression that

         do.call(foo,list(x=x,y=y))

should yield the same result as

         foo(x,y).

However if I do

         x <- 1:10
         y <- (x-5.5)^2
         do.call(plot,list(x=x,y=y))

I get the expected plot but with the y-values (surrounded by c()) being
printed (vertically) in the left-hand margin of the plot.

The help for do.call() says:

  The behavior of some functions, such as substitute, will not be the
same for functions evaluated using do.call as if they were evaluated
from the interpreter. The precise semantics are currently undefined and
subject to change.


Am I being bitten by an instance of this phenomenon?  Seems strange.

I would be grateful for enlightenment.

cheers,

Rolf Turner

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/
posting-guide.html
and provide commented, minimal, self-contained, reproducible code.





______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to