[R] median of grouped data

Felipe Carrillo mazatlanmexico at yahoo.com
Thu Jan 28 00:12:16 CET 2010


Like this?

d = read.table(textConnection("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"),head=T)
d
d$PM <- as.numeric(d$PM)
ddply(d,.(ID),numcolwise(median))



Felipe D. Carrillo  
Supervisory Fishery Biologist  Department of the Interior  US Fish & Wildlife Service  California, USA


--- On Wed, 1/27/10, "María del Pilar Márquez" <marquezvilla at wisc.edu> wrote:

> From: "María del Pilar Márquez" <marquezvilla at wisc.edu>
> Subject: [R] median of grouped data
> To: r-help at r-project.org
> Date: Wednesday, January 27, 2010, 10:05 AM
> 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