R> set.seed(123)
R> data <- matrix(rnorm(6),3,10)
R> colnames(data) <- c("s1","s2","s3","s4","s5","s6","s7","s8","s9","s10")
R> print(data)
sorry, I don't know how to show the print
I would like to get all possible combination of column from the data frame by R package? Less time is better
The result look like this,
All possible two pair combination
column S1 and S2
column S2 and S3
column S3 and S4
...
all possible three pair combination
column S1, S2 and S3
column S2, S3 and S4
column S3, S4 and S5
...
I have made a function to do this which comes in handy whenever I need it:
The function outputs a list, where each element is another list with all the 2-way, 3-way, 4-way... combinations. In your case it has 9 elements starting from the 2-way combinations all the way to the 10-way combination.