Re: [R] median of grouped data

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

On 28 , 03:19, "Bricklemyer, Ross S" <r..._at_wsu.edu> 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



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. 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive