Randomize - Cghlewis/data-wrangling-functions GitHub Wiki
There are many situations in education research where you may need to randomly sample or randomize variable values. A few examples include:
- Randomly sampling a group of participants for surveying
- Randomly assigning treatment to a group of participants
- Randomly assigning unique identifiers to participants
Randomly sample
Randomize a variable
Assign a random ID variable
Main functions used in examples
| Package | Functions |
|---|---|
| base | sample() |
| dplyr | slice_sample() |
Other functions used in examples
| Package | Functions |
|---|---|
| base | set.seed() |
| dplyr | mutate(); across(); group_by(); pull(); filter(); n(); left_join(); distinct() |
| janitor | tabyl() |
| tibble | tibble() |
| stringr | str_to_title() |
| tidyr | nest() |
Resources