Closed jeromyanglim closed 12 years ago
split(x, row(x))
returns
$`1`
[1] 1 2 3
$`2`
[1] 4 5 6
$`3`
[1] 7 8 9
where row(x)
indicates the row number of each cell and thus indicates how to split x
.
Similarly, split(x, col(x))
could be used to extract each column of a matrix as a separate vector.
Assume we have this matrix