[R] Grouping data in dataframe

Dieter Menne dieter.menne at menne-biomed.de
Wed Jul 15 08:53:00 CEST 2009




Timo Schneider wrote:
> 
> 
> 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:
> 
> 

Besides the mentioned aggregate, you could use one of the functions in
package plyr.

Dieter

-- 
View this message in context: http://www.nabble.com/Grouping-data-in-dataframe-tp24491539p24492807.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list