I don't understand it. When I'm doing this example it wirks fine, but when I'm adding the "GO:" to the beginning of the first column (as to see in my wanted result table: GO0042787 GO0016070 GO0016070
I'm getting a list of warning: Warning messages: 1: In storage.mode(xi) <- a$sm : NAs introduced by coercion 2: In storage.mode(xi) <- a$sm : NAs introduced by coercion ... 9: In storage.mode(xi) <- a$sm : NAs introduced by coercion 10: In storage.mode(xi) <- a$sm : NAs introduced by coercion What did I do wrong here? Assa On Thu, Jul 8, 2010 at 11:09, Søren Højsgaard <soren.hojsga...@agrsci.dk>wrote: > Like this? > > > library(doBy) > > (ddd <- read.table("foo.txt",header=T)) > ID gen > 1 42787 gen2 > 2 16070 gen2 > 3 16070 gen3 > 4 7409 Gen1 > 5 7409 gen3 > 6 6511 gen2 > 7 6417 gen3 > 8 16070 gen4 > 9 6511 gen4 > > aa<-lapplyBy(~ID, data=ddd, > + FUN=function(uu){ > + list(uu$ID[1], paste(uu$gen, collapse=":")) > + }) > > > > do.call(rbind,aa) > [,1] [,2] > 42787 42787 "gen2" > 16070 16070 "gen2:gen3:gen4" > 7409 7409 "Gen1:gen3" > 6511 6511 "gen2:gen4" > 6417 6417 "gen3" > > Regards > Søren > > > > > > -----Oprindelig meddelelse----- > Fra: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] På > vegne af Assa Yeroslaviz > Sendt: 8. juli 2010 10:45 > Til: r-h...@stat.math.ethz.ch > Emne: [R] transformation of data.frame > > 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. > > I will be very happy for any suggestions you might have to help me. > > Thanks > > Assa > > [[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. > [[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.