[R] dot-dot-dot as an actual argument
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Feb 19 13:22:51 CET 2010
It likely has to do with the fact that barchart uses unevaluated
arguments. Look at its source by entering its name without arguments:
barchart
This does work:
library(lattice)
f.barchart2 <- function(...) eval.parent(substitute(barchart(...)))
x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), d = c(1,2,2,1))
print(f.barchart2(a ~ b, data = x, groups = d))
On Fri, Feb 19, 2010 at 6:25 AM, Jyotirmoy Bhattacharya
<jmoy.matecon at gmail.com> wrote:
> I could not find any documentation of how dot-dot-dot works when used
> as an argument in a function call (rather than as a formal argument in
> a definition). I would appreciate some references to the rules
> governing situations like:
>
> f1<-function(x,y,...){
> print(x)
> }
>
> f2<-function(...){
> f1(...)
> }
>
> f2(1,2,3)
>
> In the call above how are the three numbers bound to the individual
> formal arguments x and y of f1 rather than f1 being called with a
> single pairlist, which is what the documentation says ... is.
>
> And while the example above succeeds, why does the following fail,
>
> library(lattice)
> f.barchart <- function(...) {
> barchart(...)
> }
>
> x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), d = c(1,2,2,1))
> print(f.barchart(a ~ b, data = x, groups = d))
>
> This gives the error:
> Error in eval(expr, envir, enclos) :
> ..3 used in an incorrect context, no ... to look in
>
> Jyotirmoy Bhattacharya
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list