treat_strings_as_exprs: treat_strings_as_exprs(arg)

Description Usage Arguments Details Value Examples

Description

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

Usage

1

Arguments

arg

a vector of strings to be treated as expressions.

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.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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)')

## End(Not run)

MilesMcBain/rlung documentation built on May 21, 2019, 9:22 a.m.