I am interested in generating the input for the example mentioned in this question. I have generated the input using the below snippet
data.frame(grade = rep(LETTERS[1:5],4,rep=TRUE),
sex = c( rep(c('male','female'), each=5), rep('male',4),rep('female', each=6)),
class=rep(c(1,2),each=10))
It gives the below output:
grade sex class
1 A male 1
2 B male 1
3 C male 1
4 D male 1
5 E male 1
6 A female 1
7 B female 1
8 C female 1
9 D female 1
10 E female 1
11 A male 2
12 B male 2
13 C male 2
14 D male 2
15 E female 2
16 A female 2
17 B female 2
18 C female 2
19 D female 2
20 E female 2
I am not sure if this is the best possible way of generating this output. Would like to know if there is any smart of doing this.
If this is not acceptable as a question, please suggest the correct way of asking it.