How can I parallelize combn()?
The function combn() generates all combinations of the elements of x taken m at a time. It is very fast and efficient for nCm small (where n is the number of elements of x) but it quickly runs out of memory. For example: > combn(c(1:50), 12, simplify = TRUE) Error in matrix(r, nrow = len.r, ncol = count) : invalid 'ncol' value (too large or NA) I would like to know if the function combn() can be modified such that it generates only k chosen combinations. Let's call this new function chosencombn(). Then we would have: > combn(c("a", "b", "c", "d"), m=2) [,1] [,2] [,3] [,4] [,5] [,6] [1,] "a" "a