Hello,
I would like to use substitute in a list to evaluate the formals
arguments using the environment define by the arguments list. For instance :
f1 <- function(x, y = 1:x){
ans <- as.list(match.call())
##possible args:
frmls <- formals(as.character(ans[[1]]))
## eval formals locally
frmls <- lapply(frmls, substitute, env = c(ans[-1], frmls))
return(c(ans, frmls))
}
f1(3)
## returns
Error in lapply(frmls, substitute, env = c(ans[-1], frmls)) :
'...' used in an incorrect context
I do not understand why. I would like to obtain something like :
[[1]]
"f1"
$x
3
$y
1:3
Any idea of the problem and what would be the correct way to implement it ?
Thanks in advance
--
Stéphane DRAY (stephane.d...@univ-lyon1.fr)
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
Tel: 33 4 72 43 27 57 Fax: 33 4 72 43 13 88
http://pbil.univ-lyon1.fr/members/dray/
______________________________________________
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.