Data Science Desktop Survival Guide
by Graham Williams
Pipeline Syntactic Sugar
# Summarise observations with little or no rainfall.
select(min_temp, max_temp, rainfall, sunshine) %>%
filter(rainfall < 1) %>%
Contrast this with how it is mapped by R into the functional construct below, which is how we might have traditionally written it. For many of us it will take quite a bit of effort to parse this traditional functional form of the expression, and so to understand what it is doing. The pipeline alternative above provides a clearer narrative.
# Functional form equivalent to the pipeline above.
min_temp, max_temp, rainfall, sunshine),
rainfall < 1))
Anything that improves the readability of our code is useful. Computers are quite capable of doing the hard work of transforming a simpler sentence into this much more complex looking sentence for its own purposes. For our purposes, let's keep it simple for others to follow.