[R] median of grouped data
cmr.Pent at gmail.com
cmr.Pent at gmail.com
Mon Jun 30 10:31:59 CEST 2008
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
More information about the R-help
mailing list