On Feb 23, 2012, at 1:41 PM, Michael Karol wrote:

R Experts



 I wish to tabulate into one data frame statistics summarizing
concentration data.   The summary is to include mean, standard
deviation, median, min and max.  I wish to have summaries by Dose, Day
and Time.   I can do this by calling aggregate once for each of the
statistics (mean, standard deviation, median, min and max) and then
execute 4 merges to merging the 5 data frames into one.  (Example
aggregate code for mean only is shown below.)

 Can someone show me the coding to do this as one command, rather than
5 calls to aggregate and 4 merges. In other words, in essence, I'd like to present to "FUN =" a list of functions, so all the summary stats come
back in one data frame.  Your assistance is appreciated.  Thank you.

Perhaps something like this?

MeansByDoseDayTime <- aggregate(as.double(DF$Concentration), by =
list(DF$Dose, DF$Day, DF$Time), FUN =
      function(x) c( mean(x, trim = 0, na.rm = T, weights=NULL),
                     sd(x, na.rm=TRUE),
                     median(x, na.rm=TRUE),
                     min(na.rm=TRUE),
                     max(x, na.rm=TRUE)
                   )
        )




David Winsemius, MD
West Hartford, CT

______________________________________________
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.

Reply via email to