Create Combinations in R by Groups

后端 未结 7 1059
一整个雨季
一整个雨季 2021-02-08 19:23

I want to create a list for my classroom of every possible group of 4 students. If I have 20 students, how I can I create this, by group, in R where my rows are each combination

7条回答
  •  孤城傲影
    2021-02-08 19:42

    This code below gives all unique combinations for 4 selected from 20 without duplicates.

    x <- c(1:20)
    combinations <- data.frame(t(combn(x, 4)))
    

提交回复
热议问题