friendlyeval (version 0.1.1)

treat_strings_as_exprs: treat_strings_as_exprs(arg)

Description

Treat the string values of a character vector as expressions in a dplyr function.

Usage

treat_strings_as_exprs(arg)

Arguments

arg

a vector of strings to be treated as expressions.

Value

something that will resolve to a list of expressions when prefixed with `!!!`

Details

This will parse a vector of strings and treat them as a list of expressions to be evaluated in the context of a dplyr function. This may be convenient when building expressions to evaluate at run time.

Examples

Run this code
# NOT RUN {
summarise_uppr <- function(dat, ...){
  ## need to capture a character vector
  dots <- as.character(list(...))
  functions <- tolower(unlist(dots))
  summarise(dat, !!!treat_strings_as_exprs(functions))
}

summarise_uppr(mtcars, 'MEAN(mpg)', 'VAR(mpg)')
# }

Run the code above in your browser using DataCamp Workspace