Skip to content

Instantly share code, notes, and snippets.

@djnavarro
Created May 23, 2019 23:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djnavarro/5cca1c905e6aa2fb1e18dbbd14fcf3f2 to your computer and use it in GitHub Desktop.
Save djnavarro/5cca1c905e6aa2fb1e18dbbd14fcf3f2 to your computer and use it in GitHub Desktop.
passing user expressions to inner functions, tidyeval and base
# tidyeval version: tidy_outer returns
# the user expression
#
# expr quotes you
# enexpr quotes user
tidy_outer <- function(x) {
tidy_inner(!!rlang::enexpr(x))
}
tidy_inner <- function(x) {
rlang::enexpr(x)
}
# base version: base_outer returns the
# user expression.
#
# - quote quotes you
# - substitute quotes user
base_outer <- function(x) {
eval(substitute(base_inner(x)))
}
base_inner <- function(x) {
substitute(x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment