mercredi 25 janvier 2023

Stratified random sampling (into 4 groups) from data frame with R

I have a data frame in the format

> head(daten_strat)
   id age gender anxiety
1   7  40      2       7
2   3  53      1       8
3   4  40      1       4
4   1  62      2       8
5   5  60      2      11
6   6  45      1       8

I would like to create 4 random groups that are as similar as possible in terms of the distribution of gender, age and anxiety.

I have already reviewed other questions and their answers here on stackoverflow. However, I could not apply them to my example. In addition, I have never done stratified randomization before. Therefore, I would be happy if someone could help me along. Many thanks in advance :)




Aucun commentaire:

Enregistrer un commentaire