(Builds on: Exploratory data analysis (1D), Data structure basics)
(Leads to: Iteration)
Functions are powerful tool for reducing the amount of duplication in your code. Reducing duplication is a good principle because it means that each “fact” in your code is only stored in one place. When the requirements of your code change (as they invariably do), you only need to make the change in a single place, reducing the chances of inconsistencies within your code.
Introduction [r4ds-19.1]
When should you write a function? [r4ds-19.2]
Functions are for humans and computers [r4ds-19.3]