Halloween Magic With Functionals

30 Oct 2014

The popularity of dplyr has led to the use of >%> and an increase in the awareness of functional programming in R. This is great, as side-effectful statements has long been one of my greatest causes of error. Errors are scary, and it’s halloween, so here’s a quick example of >%> for dplyr and ggplot, using M&M data from the University of Puget Sound’s Data Hoard. Although the dev version includes some new operators, this post covers only the standard %>% operator, which can be summarized as ` x %>% f == f(x)`

First, we load the data and produce a quick summary table by type of m&m. The >%> operator isn’t necessary here but helps keep the code structured and readable.