bquote doc and splicing data frames

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

bquote doc and splicing data frames

Antoine Fabri
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))



        [[alternative HTML version deleted]]

[hidden email] mailing list