Sorry for the non-descriptive title but I don't know whether there's a word for what I'm trying to achieve.
Let's assume that I have a list of names of different classes like
c( '1', '2', '3', '4')
I'd like to generate all possible permutation pairs out of this so that there are no reverse-duplicates. So what I'd like to have is something like
'1' '2'
'1' '3'
'1' '4'
'2' '3'
'2' '4'
'3' '4'
Note that I don't have e.g. '2' '1'
because I already have '1' '2'
. Is there an easy way to achieve this in R?
> x<-c('1','2','3','4')
> combn(x,2)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] "1" "1" "1" "2" "2" "3"
[2,] "2" "3" "4" "3" "4" "4"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With