View source: R/R04-Data_wrangling.R
camr_shuffle_groups | R Documentation |
Function that shuffles the levels of a grouping variable (e.g., treatment or intervention assignments) over participants (and optionally a within-participant variable like study visit or time point). This is useful, for example, to create a data set for an analyst-blind design.
camr_shuffle_groups(
dtf,
id,
group,
within = NULL,
include = NULL,
group_levels = NULL,
prob_levels = NULL,
save_unshuffled = TRUE,
rng_seed = NULL
)
dtf |
A data frame. |
id |
A character string, the column with participant identifiers. |
group |
A character string, the column for the grouping variable. |
within |
An optional character string, the column with the levels for a within-participant variable (e.g., time points or visits). |
include |
An optional logical vector matching in length
to the number of rows in |
group_levels |
An optional character vector, the subset
of levels of |
save_unshuffled |
Logical; if |
rng_seed |
An integer, the RNG seed to use to ensure reproducibility. |
original_freq |
Logical; if |
A data frame with shuffled group levels for the
group
variable.
Kevin Potter
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.