On 28 июн, 03:19, "Bricklemyer, Ross S" <[EMAIL PROTECTED]> 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@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.