On 24/07/2014, 2:41 AM, super wrote:
> The question is as below:
> Exercises
> 1.The following two calls look the same, but are actually different:
>   (a <- call("mean", 1:10))
> #> mean(1:10)

This one creates a call where the first argument is a vector containing
10 elements.

> (b <- call("mean", quote(1:10)))
> #> mean(1:10)

This one creates a call where the first argument is a call to the ":"
function to produce a sequence.

> identical(a, b)
> #> [1] FALSE
> What¡¯s the difference? Which one should you prefer?
> So, how i can figure out this question?  

In this case they deparse the same, but in other cases they wouldn't, e.g.

call("mean", rnorm(10))

appears quite different from

call("mean", quote(rnorm(10)))

The difference is when the evaluation takes place.  Which should you
prefer?  That's up to you.

Duncan Murdoch

______________________________________________
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