[R] median of grouped data

Peter Alspach Peter.Alspach at plantandfood.co.nz
Wed Jan 27 21:35:13 CET 2010


Tena koe Maria

?tapply

Specifically:

tapply(yourData$PM, yourData$ID, median)

HTH ....

Peter Alspach 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of "María del 
> Pilar Márquez"
> Sent: Thursday, 28 January 2010 7:06 a.m.
> To: r-help at r-project.org
> Subject: [R] median of grouped data
> 
> Good morning,
> I would like to know if is possible somebody can help me with 
> this please:
> I would like to calculate the median of grouped data, this is 
> an example:
> 
> ID    PM
> adt_01  25.255
> adt_01  225.36
> adt_01  14.2325
> adt_02  15
> adt_02  12.3
> adt_03  15.2
> adt_03  148.3
> adt_03  25.5
> adt_03  14.25
> 
> I need the median of adt_01, 02 and 03 , I know that I have 
> to split first my data and then ask for the median but the 
> code I have is not working.
> 
> Thank you very much if you can help me with the code maria
> 
> ______________________________________________
> 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