Re: [R] median of grouped data

From: <>
Date: Mon, 30 Jun 2008 01:31:59 -0700 (PDT)

On 28 , 03:19, "Bricklemyer, Ross S" <> wrote:
> I am having difficulty calculating the median of grouped data. I have 8 to 10 repeated measures per sample and I have successfully used the following code to calculate the average for each sample.
> libs.norm.preds.median[,7:9]<-apply(libs.norm.preds.median[,7:9],MARGIN=2, FUN=ave,libs.norm.preds.median[,1])

You might want to create a wrapper around "ave" like this:

myave <- function(..., ave.FUN = mean)
  ave(..., FUN = ave.FUN)

and pass needed ave.FUN parameter to "apply".

Andrey mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon 30 Jun 2008 - 08:49:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 30 Jun 2008 - 09:30:52 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive