Re: [R] Convertin rows of a matrix to a list

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Wed 22 Feb 2006 - 05:20:44 EST


Perhaps something like:

    as.list(as.data.frame(t(mat)))

Andy

From: Aleš Žiberna
>
> Hello!
>
> I would like to convert rows of a matrix to a elements of a list.
>
> #For example, if I have
> mat<-matrix(1:100,ncol=5, nrow=20)
>
> #I can do:
> list<-apply(mat,1,list)
> list
> #however this is not quite what I want. To get what I want, I
> have to do:
> list<-lapply(list,function(x)x[[1]])
> list
>
> Is there a faster way?
>
> Best regards,
> Ales Ziberna
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Feb 22 05:36:10 2006

This archive was generated by hypermail 2.1.8 : Wed 22 Feb 2006 - 09:27:47 EST