[R] how to pass extra parameters using call() or similar mechanism ?

ryszard.czerminski@pharma.novartis.com ryszard.czerminski at pharma.novartis.com
Thu Mar 11 21:03:10 CET 2004


I am trying to write a function, which would allow to call various methods
and would pass to them extra arbitrary parameters.
My first attempt was to use call() as illustrated below, but apparently
'...' cannot be used in such context.

How can this be achieved ?

Best regards,

Ryszard

> myfun <- function(method, x, ...) {
+   v <- eval(call(method, x, ...))
+ }
> method = 'sqrt'
> myfun('sqrt',2)
Error in eval(call(method, x, ...)) : ... used in an incorrect context
> eval(call(method, 2, ...))
Error in eval(call(method, 2, ...)) : ... used in an incorrect context
> eval(call(method, 2))
[1] 1.414214




More information about the R-help mailing list