Created
May 23, 2019 23:56
-
-
Save djnavarro/5cca1c905e6aa2fb1e18dbbd14fcf3f2 to your computer and use it in GitHub Desktop.
passing user expressions to inner functions, tidyeval and base
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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