Description Usage Arguments Details Value Examples
Treat the string value of a variable as an expression in a dplyr function.
1 |
x |
a string to be treated as an expression. |
This will parse a string and treat it as an expression to be evaluated in the context of a dplyr function call. This may be convenient when building expressions to evaluate at run-time.
something that will resolve to an expression when prefixed with '!!'
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
## processing operations from other notation
calc_result <- function(dat, operation){
operation <- gsub('x', '*', operation)
mutate(dat, result = !!treat_string_as_expr(operation))
}
calc_result(mtcars, "mpg x hp")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.