On 5/30/05, Charles Plessy <[EMAIL PROTECTED]> wrote: > On Mon, May 30, 2005 at 09:15:32AM +0000, zhihua li wrote : > > hi netters > > > > I have a rather simple question. I have a data frame with two variables X > > and Y, both of which are factors. X has 100 levels while Y has 10 levels > > only. The data frame has 100 rows in all, so for X the values are unique, > > and Y has many replicate values. Now I wanna reduce the data frame into 10 > > rows only, according to the 10 levels of Y. I don't care which value of X > > is in the same row with Y in the final data frame, as long as it is in > > agreement with the original data frame. > > Dear list, > > I am a new subscriber, using R to analyse genomics data. I have a > similar question, maybe even identical, but I am not sure... > > >From a data frame with two factors and one value, I would like to obtain a > >data > frame with one factor and one value per level in the removed factor. > > For instance: > > F1 F2 V > ----------------- > A X 3 > A Y 6 > B X 5 > C X 9 > C Y 3 > > Would become: > > F1 VX VY > ------------------ > A 3 6 > B 5 0 > C 9 3 > > I am sure I have seen a tool to do this some time ago, but I do not remember > its name. > Try using reshape, e.g. if dd is your data frame:
reshape(dd, dir = "wide", idvar = "F1", timevar = "F2", varying = list(c("VX","VY"))) ______________________________________________ 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