Tena koe Timo ?aggregate
HTH ... Peter Alspach > -----Original Message----- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Timo Schneider > Sent: Wednesday, 15 July 2009 3:56 p.m. > To: r-help@r-project.org > Subject: [R] Grouping data in dataframe > > Hello, > > I have a dataframe (obtained from read.table()) which looks like > > ExpA ExpB ExpC Size > 1 12 23 33 1 > 2 12 24 29 1 > 3 10 22 34 1 > 4 25 50 60 2 > 5 24 53 62 2 > 6 21 49 61 2 > > now I want to take all rows that have the same value in the "Size" > column and apply a function to the columns of these rows (for > example median()). The result should be a new dataframe with > the medians of the groups, like this: > > ExpA ExpB ExpC Size > 1 12 23 34 1 > 2 24 50 61 2 > > I tried to play with the functions by() and tapply() but I > didn't get the results I wanted so far, so any help on this > would be great! > > The reason why I am having this problem: (I explain this just > to make sure I don't do something against the nature of R.) > > I am doing 3 simillar experiments, A,B,C and I change a > parameter in the experiment (size). Every experiment is done > multiple times and I need the median or average over all > experiments that are the same. Should I preprocess my data > files so that they are completely different? Or is it fine > the way it is and I just overlooked the simple solution to > the problem described above? > > Regards, > Timo > > ______________________________________________ > 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. > The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited. ______________________________________________ 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.