R 重复元素组合

R 重复元素组合,r,R,我有下一个问题: 我正在使用函数组合,例如de vectorx=c(1,1,3),但是: combinations(n=3,r=2,v=x,repeats.allowed=F) Error in combinations(n = 3, r = 2, v = x, repeats.allowed = F) : too few different elements 我要你给我看看这个 [,1] [,2] [1,] 1 1 [2,] 1 3 [3,] 2

我有下一个问题: 我正在使用函数组合,例如de vector
x=c(1,1,3)
,但是:

combinations(n=3,r=2,v=x,repeats.allowed=F)
Error in combinations(n = 3, r = 2, v = x, repeats.allowed = F) : 
  too few different elements
我要你给我看看这个

   [,1] [,2]
[1,]    1    1
[2,]    1    3
[3,]    2    3
是否有另一个功能可用于重复元素


谢谢

t(combn(x,2))
为什么结果中有一个2?