Generate a variable used to selected a training sample
make_train(n = 0.7, nr = NULL, blocks = NULL, seed = 1234)Number (or fraction) of observations to label as training
Number of rows in the dataset
A vector to use for blocking or a data.frame from which to construct a blocking vector
Random seed
0/1 variables for filtering
make_train(.5, 10)
#> [1] 1 1 0 0 0 1 0 1 1 0
make_train(.5, 10) %>% table()
#> .
#> 0 1
#> 5 5
make_train(100, 1000) %>% table()
#> .
#> 0 1
#> 900 100
make_train(.15, blocks = mtcars$vs) %>% table() / nrow(mtcars)
#> .
#> 0 1
#> 0.84375 0.15625
make_train(.10, blocks = iris$Species) %>% table() / nrow(iris)
#> .
#> 0 1
#> 0.9 0.1
make_train(.5, blocks = iris[, c("Petal.Width", "Species")]) %>% table()
#> .
#> 0 1
#> 75 75