Last active
February 14, 2021 22:29
-
-
Save bfatemi/e099776e28c24eaa696f8b20c5afd8ac to your computer and use it in GitHub Desktop.
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
### | |
### Scenario Index Table | |
### | |
..AND <- function(..., .env = rlang::caller_env()){ | |
dd <- pryr::dots(...) | |
Reduce("&", lapply(dd, eval, envir = .env)) | |
} | |
..OR <- function(..., .env = rlang::caller_env()){ | |
dd <- pryr::dots(...) | |
Reduce("|", lapply(dd, eval, envir = .env)) | |
} | |
dt <- data.table::as.data.table(iris) | |
data.table::setnames(dt, letters[1:5]) | |
dt[..AND(a > 5, b > 3, c*d <= .3)] | |
dt[ ..OR(a > 5, b > 3, c*d <= .3)] | |
..AND(a > 5, b > 3, c*d <= .3, .env = dt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment