R中大数的所有可能组合

All possible combinations for large numbers in R

图片我有这样的序列:

seq <- rep(0:9, 10)

我想知道这个序列所有可能的组合。当然,命令 combn 不起作用:

> comb <- combn(seq, 10)
Error in matrix(r, nrow = len.r, ncol = count) : 
  invalid 'ncol' value (too large or NA)
In addition: Warning message:
In combn(seq, 10) : NAs introduced by coercion to integer range

你能告诉我如何为所有可能的组合创建我自己的函数吗?

根据您对评论的回复,您可以做一件事。你需要安装 combinat 包才能工作。

library(combinat)
seq <- c(1,2,3,4,5,6,7,8,9,0)
permn(seq)