# NOT RUN {
# Uses `sample_n`
recipe( ~ ., data = iris) %>%
step_sample(size = 1) %>%
prep(training = iris, retain = TRUE) %>%
juice() %>%
nrow()
# Uses `sample_frac`
recipe( ~ ., data = iris) %>%
step_sample(size = 0.9999) %>%
prep(training = iris, retain = TRUE) %>%
juice() %>%
nrow()
# Uses `sample_n` and returns _at maximum_ 120 samples.
smaller_iris <-
recipe( ~ ., data = iris) %>%
step_sample() %>%
prep(training = iris %>% slice(1:120), retain = TRUE)
juice(smaller_iris) %>% nrow()
bake(smaller_iris, iris %>% slice(121:150)) %>% nrow()
# }
Run the code above in your browser using DataLab