I have a dataframe with 20 classrooms [1 to 20] indexes and 20 different number of students in each class, how to obtain all sub-samples of size n = 8 and store them because i want to use them later for calculations. I used combn() but that takes only one vector, can i use it with a dataframe and how? (sorry but i’m new in R),
dataframe below:
classrooms students 1 1 29 2 2 30 3 3 35 4 4 28 5 5 32 6 6 20 7 7 25 8 8 22 9 9 32 10 10 26 11 11 27 12 12 34 13 13 27 14 14 28 15 15 33 16 16 21 17 17 36 18 18 24 19 19 19 20 20 32
It is as simple as passing a function to
combn.simplify = FALSEmeans that a list will be returned.Assuming you want all possible combinations of 8 classrooms from the dataset classrooms