The main difficulty has to do with capturing the inputs.
I do not know of an easy way to turn a list of unquoted expressions passed through as the argument to a function into a list of quoted expressions. For instance, this doesn't work
prj_tbl_set(
mtcars,
vars(
Cylinders = cyl,
Transmission = am
),
vars(
`V-Shaped` = col_freq(n = vs %in% 1, N = vs %in% 0:1),
`Not V-shaped` = col_freq(n = vs %in% 0, N = vs %in% 0:1)
)
)
The only thing I don't like about this is that it's inconsistent with the API of the other prj_tbl_*() functions where you pass through unquoted expressions. The equivalent to the above would be (using pipes)
mtcars %>%
prj_tbl_rows(
Cylinders = cyl,
Transmission = am
) %>%
prj_tbl_cols(
`V-Shaped` = col_freq(n = vs %in% 1, N = vs %in% 0:1),
`Not V-shaped` = col_freq(n = vs %in% 0, N = vs %in% 0:1)
)
The main difficulty has to do with capturing the inputs.
I do not know of an easy way to turn a list of unquoted expressions passed through as the argument to a function into a list of quoted expressions. For instance, this doesn't work
Because
rlang::enexprs(.rows)
just captures the expressionlist(...)
but we want a list of captured expressions.The best alternative is to re-export
rlang::exprs()
asprojectable::vars()
or something and then haveSo the user writes
The only thing I don't like about this is that it's inconsistent with the API of the other
prj_tbl_*()
functions where you pass through unquoted expressions. The equivalent to the above would be (using pipes)