I'm trying to make combinations of value using combinations
function in gtools
package.
For example, I have vector cat_var
cat_var<-c("James","Ariana","Kevin","Bob")
Then, I want to make
James Ariana
James Kevin
James Bob
Ariana Kevin
Ariana Bob
Kevin Bob
However, when I used combinations
function, combination was made by alphabetical order, like
> cat_var<-c("James","Ariana","Kevin","Bob")
> combinations(n = length(cat_var), r = 2, v = cat_var, repeats.allowed = FALSE)
[,1] [,2]
[1,] "Ariana" "Bob"
[2,] "Ariana" "James"
[3,] "Ariana" "Kevin"
[4,] "Bob" "James"
[5,] "Bob" "Kevin"
[6,] "James" "Kevin"
How to make combinations with pre-defined order?