I have a dataframe with columns
cols <- c("X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8")
Now I am using combn() function to get all possible k-subsets, i.e. k = 4.
combs <- combn(cols, 4)
What I get with class(combs) is
[1] "matrix" "array"
And this is stored as chr [1:280] behaving like a matrix, so by writing combs[, 1:5] I get i.e.
[,1] [,2] [,3] [,4] [,5]
[1,] "X1" "X1" "X1" "X1" "X1"
[2,] "X2" "X2" "X2" "X2" "X2"
[3,] "X3" "X3" "X3" "X3" "X3"
[4,] "X4" "X5" "X6" "X7" "X8".
Now, I would like to transform it into an array (or a list) such that I have only one row and for each column I have a vector made of values in each column, so, for the first two columns it would go like this:
[,1] [,2]
[1,] c("X1", "X2", "X3", "X4") c("X1", "X2", "X3", "X5")
EDIT! I need it to create a dataframe that looks like this:
X1 X2
1 c("X1", "X2", "X3", "X4") a
2 c("X1", "X2", "X3", "X5") b
.
.
.
Where a,b are some constants I populate my dataframe with.