Try this:

c(unname(as.data.frame(a)))


On Tue, Jan 18, 2011 at 10:53 AM, Feng Li <m...@feng.li> wrote:

> Dear R,
>
> Is there an efficient way to make a list that each element is from the
> corresponding column of a matrix. For example, if I have a matrix "a"
>
> > a <- matrix(1:10, 5, 2)
> > a
>     [,1] [,2]
> [1,]    1    6
> [2,]    2    7
> [3,]    3    8
> [4,]    4    9
> [5,]    5   10
>
> I would like to have a list "b" like this
>
> > b <- list(a[, 1], a[, 2])
> > b
> [[1]]
> [1] 1 2 3 4 5
>
> [[2]]
> [1]  6  7  8  9 10
>
>
> Thanks in advance!
>
>
> Feng
>
> --
> Feng Li
> Department of Statistics
> Stockholm University
> 106 91 Stockholm, Sweden
> http://feng.li/
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to