.randomize_internal | R Documentation |
This function takes a data frame and adds a new column named "treated" with randomly assigned TRUE/FALSE values. Randomization can be done either on the entire data frame or stratified by specified columns. The probability of being assigned to the treatment group can be specified, with a default of 0.5.
.randomize_internal(data, group_by = NULL, seed = NULL, pr_treated = 0.5)
data |
The input data frame. |
group_by |
(Optional) A character vector of column names to stratify the randomization. If provided, the randomization will be done within d each groupefined by the specified columns. |
seed |
(Optional) An integer to set the random seed for reproducibility. |
pr_treated |
(Optional) The probability of a row being assigned to the treatment group (TRUE). Default is 0.5. |
A new data frame with the added "treated" column.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.