Fix/functions probably typos (#1488)

* probably a typo

* MAPE: Mean Absolute Percentage Error

* a typo

* a typo

* typo
This commit is contained in:
Mitsuo Shiota 2023-10-26 11:17:44 +09:00 committed by GitHub
parent cd9f3a6746
commit 6431e4b417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -27,7 +27,7 @@ In this chapter, you'll learn about three useful types of functions:
- Data frame functions take a data frame as input and return a data frame as output.
- Plot functions that take a data frame as input and return a plot as output.
Each of these sections include many examples to help you generalize the patterns that you see.
Each of these sections includes many examples to help you generalize the patterns that you see.
These examples wouldn't be possible without the help of folks of twitter, and we encourage follow the links in the comment to see original inspirations.
You might also want to read the original motivating tweets for [general functions](https://twitter.com/hadleywickham/status/1571603361350164486) and [plotting functions](https://twitter.com/hadleywickham/status/1574373127349575680) to see even more functions.
@ -279,7 +279,7 @@ n_missing <- function(x) {
```
You can also write functions with multiple vector inputs.
For example, maybe you want to compute the mean absolute prediction error to help you compare model predictions with actual values:
For example, maybe you want to compute the mean absolute percentage error to help you compare model predictions with actual values:
```{r}
# https://twitter.com/neilgcurrie/status/1571607727255834625
@ -349,7 +349,7 @@ Once you start writing functions, there are two RStudio shortcuts that are super
Vector functions are useful for pulling out code that's repeated within a dplyr verb.
But you'll often also repeat the verbs themselves, particularly within a large pipeline.
When you notice yourself copying and pasting multiple verbs multiple times, you might think about writing a data frame function.
Data frame functions work like dplyr verbs: they take a data frame as the first argument, some extra arguments that say what to do with it, and return a data frame or vector.
Data frame functions work like dplyr verbs: they take a data frame as the first argument, some extra arguments that say what to do with it, and return a data frame or a vector.
To let you write a function that uses dplyr verbs, we'll first introduce you to the challenge of indirection and how you can overcome it with embracing, `{{ }}`.
With this theory under your belt, we'll then show you a bunch of examples to illustrate what you might do with it.
@ -395,7 +395,7 @@ This is a problem of indirection, and it arises because dplyr uses **tidy evalua
Tidy evaluation is great 95% of the time because it makes your data analyses very concise as you never have to say which data frame a variable comes from; it's obvious from the context.
The downside of tidy evaluation comes when we want to wrap up repeated tidyverse code into a function.
Here we need some way to tell `group_mean()` and `summarize()` not to treat `group_var` and `mean_var` as the name of the variables, but instead look inside them for the variable we actually want to use.
Here we need some way to tell `group_by()` and `summarize()` not to treat `group_var` and `mean_var` as the name of the variables, but instead look inside them for the variable we actually want to use.
Tidy evaluation includes a solution to this problem called **embracing** 🤗.
Embracing a variable means to wrap it in braces so (e.g.) `var` becomes `{{ var }}`.
@ -886,7 +886,7 @@ This makes it very obvious that something unusual is happening.
## Summary
In this chapter, you learned how to write functions for three useful scenarios: creating a vector, creating a data frames, or creating a plot.
In this chapter, you learned how to write functions for three useful scenarios: creating a vector, creating a data frame, or creating a plot.
Along the way you saw many examples, which hopefully started to get your creative juices flowing, and gave you some ideas for where functions might help your analysis code.
We have only shown you the bare minimum to get started with functions and there's much more to learn.