[R] Question about "evalq"

From: ronggui <ronggui.huang_at_gmail.com>
Date: Sun, 27 May 2007 11:47:49 +0800


The help page of eval says: The 'evalq' form is equivalent to 'eval(quote(expr), ...)'. But the following is not equivalent. Can anyone give me some explaination? Thanks very much.

> f1 <- function(x,digits=5) lapply(x, f2)
> f2 <- function(x) eval(quote(print(x+1,digits=digits)),list(x=x),parent.frame(2))
> f1(list(x1=1))

[1] 2
$x1
[1] 2

>
> f1 <- function(x,digits=5) lapply(x, f2)

> f2 <- function(x) evalq(print(x+1,digits=digits),list(x=x),parent.frame(2))

> f1(list(x1=1))

Error in print.default(x + 1, digits = digits) :   object "digits" not found

-- 
Ronggui Huang
Department of Sociology
Fudan University, Shanghai, China

______________________________________________
R-help_at_stat.math.ethz.ch 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.
Received on Sun 27 May 2007 - 03:52:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 27 May 2007 - 07:31:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.