[Rd] bquote doc and splicing data frames
Antoine Fabri
@nto|ne@|@br| @end|ng |rom gm@||@com
Thu Sep 24 18:56:46 CEST 2020
Dear r-devel,
The doc of bquote doesn't describe what inputs are allowed in `..()`, it
says :
*terms wrapped in ..() are evaluated and spliced into a call.*
I think "terms" is not clear enough, it might make the user think that
several arguments are possible, and the fact that `..()` (and `.()` as well
for that matter) ignores silently arguments after the first doesn't help.
The examples show us the usage with an expression.
exprs <- expression(x <- 1, y <- 2, x + y)
bquote(function() {..(exprs)}, splice = TRUE)
In fact any object satisfying `is.vector()` will work.
Which brings me to my second and main point. `..()` will work on standard
lists but not on data.frames. Is there a good reason for that ? It is handy
indeed to splice data frames:
x <- head(cars,3)
bquote(pmax(..(x)), splice = TRUE)
#> Error in unquote.list(e) : can only splice vectors
x <- as.list(x)
bquote(pmax(..(as.list(x))), splice = TRUE)
#> pmax(speed = c(4, 4, 7), dist = c(2, 10, 4))
Best,
Antoine
[[alternative HTML version deleted]]
More information about the R-devel
mailing list