[R] Nested structure data simulation
varin sacha
v@r|n@@ch@ @end|ng |rom y@hoo@|r
Sat May 18 15:57:06 CEST 2019
Dear R-Experts,
In a data simulation, I would like a balanced distribution with a nested structure for classroom and teacher (not for school). I mean 50 pupils belonging to C1, 50 other pupils belonging to C2, 50 other pupils belonging to C3 and so on. Then I want the 50 pupils belonging to C1 with T1, the 50 pupils belonging to C2 with T2, the 50 pupils belonging to C3 with T3 and so on. The school don’t have to be nested, I just want a balanced distribution, I mean 60 pupils in S1, 60 other pupils in S2 and so on.
Here below the reproducible example.
Many thanks for your help.
##############
set.seed(123)
# Génération aléatoire des colonnes
pupils<-1:300
classroom<-sample(c("C1","C2","C3","C4","C5","C6"),300,replace=T) teacher<-sample(c("T1","T2","T3","T4","T5","T6"),300,replace=T) school<-sample(c("S1","S2","S3","S4","S5"),300,replace=T)
##############
More information about the R-help
mailing list