stratify: Stratify a data frame

View source: R/splitting.R

stratifyR Documentation

Stratify a data frame

Description

Split a dataframe into strata formed by each a unique value of stratification.

Usage

stratify(ds, stratification = NULL)

Arguments

ds

(data frame) data to split into strata

stratification

(vector). Vector that identifies which subsets of data should be split separately (denoted as strata in splitting functions) in order to ensure they are evenly distributed between patrs. If NULL, all data is considered a single stratum.

Value

(list) List of strata

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_df(), split_strata(), split_stratum()

Examples

# Stratify a data frame, then split it odd-even
ds <- data.frame(condition = rep(c("a", "b"), each = 4), score = 1 : 8)
strata <- stratify(ds, ds$condition)
split_strata(strata, method = "odd_even")

splithalfr documentation built on Sept. 15, 2023, 1:08 a.m.