Created
September 25, 2020 10:51
-
-
Save thomas-neitmann/bf703d36b0ca5b5162cf0ba72dbeed73 to your computer and use it in GitHub Desktop.
This file contains 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
do_if <- function(data, predicate, expr) { | |
if (predicate) { | |
eval.parent(insert_data( | |
substitute(expr), | |
substitute(data) | |
)) | |
} else { | |
data | |
} | |
} | |
insert_data <- function(expr, data) { | |
as.call(c( | |
expr[[1L]], | |
data, | |
as.list(expr[-1L]) | |
)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment