Let's say you have the following vector of numbers:
1, 2, 3, 4, 5
I want to find all possible combinations of numbers with the combination length 3. The combinations must not overlap, ie 1, 2, 3
is the same as 1, 3, 2
and only one of those should appear in the output!
So, the answers would be:
1, 2, 3
1, 2, 4
1, 2, 5
1, 3, 4
1, 3, 5
1, 4, 5
2, 3, 4
2, 3, 5
2, 4, 5
3, 4, 5
This is just a simple example, in reality I have a vector of length 10000 and I need to find all combinations with length 8000. What code would you use to generate those combinations in R?
@chinsoon12 suggested the package RcppAlgos
. I investigated it and found that the following works:
comboIter(1:10000, 8000)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.