How to generate all possible combinations of vectors without caring for order?

There’s the combn function in the utils package:

t(combn(LETTERS[1:3],2))
#      [,1] [,2]
# [1,] "A"  "B" 
# [2,] "A"  "C" 
# [3,] "B"  "C"

I’m a little confused as to why your x has duplicated values.

Leave a Comment