Convert a matrix to a list of vectors in R -
what elegant way of converting matrix list, each element of list vector containing elements in row of matrix?
a couple of approaches
assuming matrix called foo
lapply(seq_len(nrow(foo)), function(x) foo[x,])
or less efficiently.
lapply(apply(foo,1,list), unlist)
Comments
Post a Comment