x <- split_strata(iris, "Sepal.Length",
strata = c("Species"),
split = "setosa", split_var = "Sepal.Width",
split_at = c(0.5), type = "global quantile"
)
# You can split at more than one quantile in one call.
# The above call splits the "setosa" stratum into three of equal size
x <- split_strata(iris, "Sepal.Length",
strata = c("Species"),
split = "setosa", split_var = "Sepal.Width", split_at = c(0.33, 0.66),
type = "local quantile"
)
# Manually select split values with type = "value"
x <- split_strata(iris, "Sepal.Length",
strata = "Species",
split = "setosa", split_var = "Sepal.Width",
split_at = c(3.1, 3.8), type = "value"
)
# Perform a categorical split.
iris$strata <- rep(c(rep(1, times = 25), rep(0, times = 25)), times = 3)
x <- split_strata(iris, "Sepal.Length",
strata = "strata",
split = NULL, split_var = "Species",
split_at = c("virginica", "versicolor"), type = "categorical"
)
# Splits each initial strata 1 and 2 into one stratum with "virginia"
# and "versicolor" species and one stratum with all of the other species
# not specified in the split_at argument.
Run the code above in your browser using DataLab