I have to make a random sampling (nested in a systematic) on a dataset. I have already done a part of algorithm to obtain the sample, but I'm lost in a part, where I have to implement the follow: I have three groups of observations (divided by a factor), but for all, sorted by variables a,b,c,d I have to give a priority for the sampling, for example:
by Factor: 1,2,3
id: 001,002,003
fac a: a,b,c
fac b: d,e,f
fac c: z,x,y
num d: 1,...
This means that: if in the output file I have already for the id 001 the first level of "fac a", sample only the second level, else the third, else the first. And then, take the second factor variable, and make the same, then write in the output file. The same for every id (I've done already the loop). What I can't solve, is to use sample(), or maybe another function, with all these conditions by ordered variables.
Aucun commentaire:
Enregistrer un commentaire