user1747856
user1747856

Reputation: 11

random group generator in R

I have a data set consisting of 250 students from different schools and classrooms. For the experimental design, I would like to generate in a random manner 35 groups consisting of approx. 7 students in each group, and then after the first activity, break up the students as randomly as possible in to 25 groups of 10 students each. Is there a package and example of how I can perform this in R?

Upvotes: 1

Views: 4375

Answers (1)

Richard
Richard

Reputation: 61289

If there's no relation between which groups students are in during the first and second activities, then it's the same problem twice over.

Assuming a student can only belong to one group at a time, just shuffle the array and pull out elements per your group size until there are no more left.

students=1:250;
rand_students=sample(students,length(students));

Upvotes: 1

Related Questions