The ChickWeight
data is divided by the mean weight
of all chicks in the respective times using the aggregate
function.
chick_avgdiet <- aggregate(list(Weight=ChickWeight$weight), by=c(list(Diet=ChickWeight$Diet), list(Time=ChickWeight$Time)), FUN=mean) head(chick_avgdiet)
## Diet Time Weight ## 1 1 0 41.40 ## 2 2 0 40.70 ## 3 3 0 40.80 ## 4 4 0 41.00 ## 5 1 2 47.25 ## 6 2 2 49.40