I have the following:
a <- matrix(c(1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0), nrow = 2, ncol = 7, byrow = T)
> a
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 1 1 0 0 0 0 0
[2,] 0 1 0 1 1 0 0
When I try to convert a
to a vector with:
b <- split(a, rep(1:nrow(a), each = ncol(a)))
> b
$`1`
[1] 1 0 1 1 0 0 0 # suppose to be 1 1 0 0 0 0 0
$`2`
[1] 1 0 1 0 0 0 0 # suppose to be 0 1 0 1 1 0 0
I did not get the expected output of 1100000
and 0101100
. It looked like the vector is filled by column first. How can I do the opposite?