Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] Problems with eval() in connection with match.call()

Søren Højsgaard

2005-07-04

Replies:

Dear all, I have a problem when passing parms from one function to another when the argument list is just '...'. Consider this example:

foo<-function(){
xx <- 111222
bar(x=xx)
}
bar <- function(...){
cl <- match.call(expand.dots=TRUE)
print(cl)
x <- eval(cl$x)
print(x)
}
foo()

> bar(x = xx)
> Error in eval(expr, envir, enclos) : Object "xx" not found

My expectation was, that xx would be evaluated to 111222 in foo before being passed on to bar, but obviously it is not so. Should I do something explicitely in foo() to 'evaluate' xx or need I do something special in bar()??

Thanks in advance, Søren

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.