[R] Creating lists from matrices
Alexander Sokol
alexandersokol at ofir.dk
Thu Nov 25 10:12:28 CET 2004
Hello,
I am using R 1.9.1 on Windows 2000 SP4. I have the following problem:
Say I have a matrix,
>my.matrix
[,1] [,2] [,3]
[1,] "A" "B" "C"
[2,] "D" "E" "F"
[3,] "G" "H" "I"
I would like to apply an operation to this matrix which returns a list my.list
containing the following 3 elements,
>my.list
[[1]]
[1] "A" "B" "C"
[[2]]
[2] "D" "E" "F"
[[3]]
[3] "G" "H" "I"
That is, each row of the original matrix is turned into a vector and these
vectors are collected to a list. How do I do this?
Thanks,
Alexander
More information about the R-help
mailing list