summaryBy {doBy} | R Documentation |
Function to calculate groupwise summary statistics, much like the summary procedure of SAS
summaryBy(formula, data = parent.frame(), id = NULL, FUN = mean,...)
formula |
A formula object, see examples below |
data |
A data frame |
id |
A formula specifying variables which data are not grouped by but which should appear in the output. See examples below. |
FUN |
A list of functions to be applied, see examples below. |
... |
Additional arguments to FUN. |
NAs are removed before calculating summary statistics
A data frame
Søren Højsgaard, sorenh@agrsci.dk
data(dietox) dietox12 <- subset(dietox,dietox$Time==12) summaryBy(Weight+Feed~Evit+Cu, data=dietox12, FUN=c(mean,var), na.rm=TRUE) summaryBy(Weight+Feed~Evit+Cu+Time, data=subset(dietox,Time>1), FUN=c(mean,var), na.rm=TRUE) summaryBy(Weight+Feed~Evit+Cu, data=dietox12, FUN=length) summaryBy(log(Weight)+Feed~Evit+Cu, data=dietox12) summaryBy(.~Evit+Cu, data=dietox12, id=~Litter, FUN=mean) data(warpbreaks) summaryBy(breaks ~ wool+tension, warpbreaks) summaryBy(breaks ~., warpbreaks) summaryBy(.~ wool+tension, warpbreaks) summaryBy(Ozone~Month, data=airquality,FUN=c(mean,var),na.rm=TRUE)