Martin Spindler wrote: > I have a matrix X which consists of 2 columns. I would like to convert this > matrix into a list where every entry of the list consists of a single row of > the matrix.
Here's another way besides split(): # returns a list of the matrix m's rows (rowcol=1) or columns mat2lst <- function(m,rowcol=1) { if (rowcol == 1) m <- t(m) dm <- as.data.frame(m) as.list(dm) } This seems to be faster than the split() approach for columns, but slower for rows. Apparently the transpose operation makes the difference. (You could try investigating via Rprof().) Norm Matloff ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.