[R] Row-wisely converting a data frame into a list
Sebastian Bauer
Sebastian.Bauer at charite.de
Tue Mar 2 14:35:44 CET 2010
Hi!
On 03/02/2010 02:22 PM, Nutter, Benjamin wrote:
>> as.data.frame(t(df))
>
> For example
>
>> x<- as.data.frame(t(mtcars))
>> typeof(x)
> [1] "list"
Thanks for the quick reply!
I would never have guessed that as.data.frame() works that way!
BTW
This one seems also to do the trick:
rows.to.list <- function( df ) {
ll<-apply(df,1,list)
ll<-lapply(ll,unlist)
}
It's even a bit faster here.
Bye,
Sebastian
More information about the R-help
mailing list