Last active
January 22, 2017 04:07
-
-
Save kylebaron/282e5a2c33c25f05e12e38c245bf630f to your computer and use it in GitHub Desktop.
Test environments with dmutate
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
| a <- 10 | |
| b <- 10 | |
| data <- data.frame(ID=1:5) | |
| test <- function(obj,envir) { | |
| a <- 100 | |
| if(missing(obj)) { | |
| obj <- Y~runif(a,a+b) | |
| } | |
| if(missing(envir)) { | |
| data %>% mutate_random(obj) | |
| } else { | |
| data %>% mutate_random(obj,envir=envir) | |
| } | |
| } | |
| #' # Case 0 | |
| data %>% mutate_random(Y~runif(a,a+b)) | |
| data %>% mutate_random(Y~runif(a,a+b),list(a=10000,b=300)) | |
| #' # Case 1 | |
| obj <- Y~runif(a,a+b) | |
| test(obj) | |
| #' Case 2 | |
| test() | |
| #' Case 3 | |
| test(obj, list(a=-1000,b=300)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment