【发布时间】:2016-11-03 07:22:23
【问题描述】:
我曾尝试使用 combn 和 gtools 库搜索并尝试解决方案,但均无济于事。
我想取以下向量:
x<-c(TRUE,FALSE)
并让它看起来像以下输出:
Permutations with repetition (n=2, r=5)
Using Items: t,f
List has 32 entries.
{t,t,t,t,t} {t,t,t,t,f} {t,t,t,f,t} {t,t,t,f,f} {t,t,f,t,t} {t,t,f,t,f} {t,t,f,f,t} {t,t,f,f,f} {t,f,t,t,t} {t,f,t,t,f} {t,f,t,f,t} {t,f,t,f,f} {t,f,f,t,t} {t,f,f,t,f} {t,f,f,f,t} {t,f,f,f,f} {f,t,t,t,t} {f,t,t,t,f} {f,t,t,f,t} {f,t,t,f,f} {f,t,f,t,t} {f,t,f,t,f} {f,t,f,f,t} {f,t,f,f,f} {f,f,t,t,t} {f,f,t,t,f} {f,f,t,f,t} {f,f,t,f,f} {f,f,f,t,t} {f,f,f,t,f} {f,f,f,f,t} {f,f,f,f,f}
有什么建议吗?我是这方面的新手,所以任何帮助表示赞赏。我使用以下在线计算器为我提供了以下解决方案。 https://www.mathsisfun.com/combinatorics/combinations-permutations-calculator.html
谢谢!
【问题讨论】:
-
expand.grid(x,x,x,x,x) -
你可以传递
expand.grid一个列表,如果你喜欢:expand.grid(rep(list(c(TRUE, FALSE)), 5))
标签: r combinations permutation