I need to get out a sample of subjects from a list to assign them as a Control Group for a study which has to have a similar composition of variables. I am trying to do this in R with the sample function but I don´t know how to specify the differetnt probabilities for each variable. Lets say I have a table with the following headers:
ID Name Campaign Gender
I need a sample of 10 subjects with the following composition of Campaign attributes:
D2D --> 25%
F2F --> 38%
TM --> 17%
WW --> 21%
This means from my data set I have 25% of subjects coming from a Door to Door Campaign (D2D), 38% from a Face to Face Campaign (F2F), etc
And the gender composition is as following:
Male --> 54%
Female --> 46%
When I get a random sample of 10 subjects I need it to have a similar composition.
I have been searching for hours and the closest I was able to get to anything similar was this answer: taking data sample in R but I need to assign more than one probability.
I am sure that this could help anyone who wants to get a representative sample from a Data Set.