16.7 OPTIONAL: Alternatives to dplyr

This section is optional

Most everybody is switching to dplyr. Below are some other idioms you may see others use or encounter in older books (or my old code).

16.7.1 doBy::summaryBy

The doBy package has a nice syntax. I don’t really see many people use it. Be sure to download it first.

library(doBy)
summaryBy(mass ~ sex,data = my.frogs, FUN = mean)

summaryBy(mass ~ sex,data = my.frogs, FUN = c(mean,sd))

16.7.2 tapply()

tapply is pretty old school. You might see people working with big dat get into arguements about whether its faster than dplyr.

tapply(X = my.frogs$mass,INDEX = my.frogs$sex, FUN = mean)

16.7.3 reshape2::dcast

What I’ve used most of my career thus far. Am slowly switch to dplyr.

library(reshape2)
dcast(data = my.frogs,
      formula = sex ~ .,
      value.var = "mass",
      fun.aggregate  = mean)

End optional section