Reword amount of code reduction (#685)

* Update iteration.Rmd

* Update iteration.Rmd

Rewording the amount of code reduction due to generalizing code with a function
This commit is contained in:
twgardner2 2018-10-24 13:26:03 -04:00 committed by Hadley Wickham
parent c63f496ed9
commit 38cd5aa337
1 changed files with 1 additions and 1 deletions

View File

@ -438,7 +438,7 @@ Hopefully, you'd notice that there's a lot of duplication, and extract it out in
f <- function(x, i) abs(x - mean(x)) ^ i
```
You've reduced the chance of bugs (because you now have 1/3 less code), and made it easy to generalise to new situations.
You've reduced the chance of bugs (because you now have 1/3 of the original code), and made it easy to generalise to new situations.
We can do exactly the same thing with `col_mean()`, `col_median()` and `col_sd()` by adding an argument that supplies the function to apply to each column: