split_df {splithalfr} | R Documentation |
Split a data frame into two parts
Description
Splits data
, Applies a stratified split to a data frame and returns
each part. For more information about splitting options, and an extensive
list of examples, see get_split_indexes_from_stratum
.
Usage
split_df(data, stratification = NULL, ...)
Arguments
data |
(data frame) Data to split, in long format, with one row per observation. |
stratification |
(vector). Vector that identifies which subsets of
|
... |
Arguments passed on to
|
Value
(list) List with two elements that each contain one of two parts.
See Also
Other splitting functions:
apply_split_indexes_to_strata()
,
apply_split_indexes_to_stratum()
,
check_strata()
,
get_split_indexes_from_strata()
,
get_split_indexes_from_stratum()
,
split_strata()
,
split_stratum()
,
stratify()
Examples
ds <- data.frame(condition = rep(c("a", "b"), each = 4), score = 1 : 8)
split_df(ds, method = "random")
split_df(ds, method = "odd_even")
split_df(ds, method = "first_second")
split_df(ds, stratification = ds$condition, method = "random")
split_df(ds, stratification = ds$condition, method = "odd_even")
split_df(ds, stratification = ds$condition, method = "first_second")
ds <- data.frame(condition = rep(c("a", "b"), 4), score = 1 : 8)
split_df(ds, method = "random")
split_df(ds, method = "odd_even")
split_df(ds, method = "first_second")
split_df(ds, stratification = ds$condition, method = "random")
split_df(ds, stratification = ds$condition, method = "odd_even")
split_df(ds, stratification = ds$condition, method = "first_second")