samedi 13 novembre 2021

Sampling while keeping the same ratio in multiple categorical variables between 2 groups

I have a dataset with 4 variables. The first one is 'Group' (G1 and G2) and the other 3 are categorical variables A B and C with 3 outcomes each (A1 A2 A3, B1 B2 B3, C1 C2 C3). I want to create a sample from the initial dataset which contains the same ratio between 2 groups G1 and G2 for each of 3 variables (For example 40%A1 30%A2 30%A3 in G1 and also G2). How can I code that in R in order to have the biggest sample size possible?




Aucun commentaire:

Enregistrer un commentaire