Histograms and Density Plots in ggplot2
Now you will learn the ggplot2 syntax for building and customizing histograms.
Change histogram plot colors by groups:
Calculate the mean of each group
The package plyr is used to calculate the average weight of each group :
library(plyr) mu <- ddply(df, "sex", summarise, grp.mean=mean(weight)) head(mu)
## sex grp.mean ## 1 F 54.70 ## 2 M 65.36