strat_permute_group {permutest} | R Documentation |
This function takes a data frame and group and strata column name as input and returns the dataframe with the group column randomly permuted by strata
strat_permute_group(df, group_col, strata_col, seed = NULL)
df |
A data frame |
group_col |
The name of the column in df that corresponds to the group label |
strata_col |
The name of the column in df that corresponds to the strata |
seed |
An integer seed value |
The inputted data frame with the group column randomly shuffled by strata
data <- data.frame(group_label = c(1, 2, 2, 1, 2, 1), stratum = c(1, 1, 1, 2, 2, 2), outcome = 1:6)
permute_group(df = data, group_col = "group_label", strata_col = "stratum", seed = 42)