x <- letters[1:4]
x
# [1] "a" "b" "c" "d"
t(combn(x, 2))
# [,1] [,2]
# [1,] "a" "b"
# [2,] "a" "c"
# [3,] "a" "d"
# [4,] "b" "c"
# [5,] "b" "d"
# [6,] "c" "d"
How should I write the code if I also what inverse combinations with b-a, c-a...d-c. 12 combinations in total.