[R] Odp: transformation of data.frame

Petr PIKAL petr.pikal at precheza.cz
Thu Jul 8 11:15:43 CEST 2010


Hi

r-help-bounces at r-project.org napsal dne 08.07.2010 10:45:04:

> Hello all R users,
> 
> I have a problems transforming (or maybe better regrouping) a 
data.frame.
>  I have a big data.frame, which I would like to sum up according to a
> specific column.
> 
> This is an example of my matrix:
> ID    gen
> 0042787    gen2
> 0016070    gen2
> 0016070    gen3
> 0007409    Gen1
> 0007409    gen3
> 0006511    gen2
> 0006417    gen3
> 0016070    gen4
> 0006511    gen4
> 
> I want to rearrange the matrix according to column GO, so that it will 
look
> likes that:
> 
> GO:0042787     gen2
> GO:0016070    gen2  :  gen3  :  gen4
> GO:0007409    gen1  :  gen3
> GO:0006511    gen2  :  gen4
> GO:0006417    gen3
> 
> I've tried it with the package doBy (lapplyBy and paste) but it just 
doesn't
> work out.

Perhaps

aggregate(test$gen, list(test$ID), function(x) paste(x, collapse=":"))

Regards
Petr

> 
> I will be very happy for any suggestions you might have to help me.
> 
> Thanks
> 
> Assa
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list