Skip to content
Back to formatted view

Raw Message

Message-ID: <43FB5713.40808@gmail.com>
Date: 2006-02-21T18:08:19Z
From: Aleš Žiberna
Subject: Convertin rows of a matrix to a list

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