【发布时间】:2018-03-31 09:27:08
【问题描述】:
R 中的函数combn(x,m) 一次生成元素x 的所有组合。例如,
t(combn(5,2))
[,1] [,2]
[1,] 1 2
[2,] 1 3
[3,] 1 4
[4,] 1 5
[5,] 2 3
[6,] 2 4
[7,] 2 5
[8,] 3 4
[9,] 3 5
[10,] 4 5
如何在 python 中获得相同的结果?我知道scipy.misc.comb 只给出结果而不是列表,我还阅读了this article,它看起来不同,首先需要一个给定的列表,而不仅仅是两个整数。
【问题讨论】:
标签: python r combinations