Hi, R-help,

(sessionInfo at the end)

I'm trying to construct a function using bquote and running into a strange error message. As an example, what I would like to do is this:

z <- 2
eval(bquote(function(x, y) { x^.(z) + y }))(2, 3)

However, I get the following:

Error in eval(expr, envir, enclos) :
  invalid formal argument list for "function"

However, if I change the command to following, it works:

z <- 2
eval(bquote(function(x) { x^.(z) }))(2)
# [1] 4

In other words, I remove the second argument. Is there a workaround for this without using eval(parse(text = ))?

Thanks,

--sundar

> sessionInfo()
R version 2.7.2 (2008-08-25)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

______________________________________________
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