Minor typos (#689)

* Fix a few minor typos

Examples include saying we'll learn about filter() in the next chapter, but it's not until chapter 5.  And, also, it says we'll learn about how to use multiple geoms in the same plot in the next section, but then not far below, in the same section, it shows how to use multiple geoms.

* Three minor fixes in chapter 5

* Remove " I introduced in prior commit
This commit is contained in:
DSGeoff 2018-10-24 12:25:11 -05:00 committed by Hadley Wickham
parent 86653389e3
commit d1a63fe379
2 changed files with 8 additions and 8 deletions

View File

@ -410,7 +410,7 @@ There are many functions for creating new variables that you can use with `mutat
cummean(x)
```
* Logical comparisons, `<`, `<=`, `>`, `>=`, `!=`, which you learned about
* Logical comparisons, `<`, `<=`, `>`, `>=`, `!=`, and `==`, which you learned about
earlier. If you're doing a complex sequence of logical operations it's
often a good idea to store the interim values in new variables so you can
check that each step is working as expected.
@ -558,7 +558,7 @@ flights %>%
summarise(mean = mean(dep_delay, na.rm = TRUE))
```
In this case, where missing values represent cancelled flights, we could also tackle the problem by first removing the cancelled flights. We'll save this dataset so we can reuse in the next few examples.
In this case, where missing values represent cancelled flights, we could also tackle the problem by first removing the cancelled flights. We'll save this dataset so we can reuse it in the next few examples.
```{r}
not_cancelled <- flights %>%

View File

@ -36,7 +36,7 @@ Let's use our first graph to answer a question: Do cars with big engines use mor
### The `mpg` data frame
You can test your answer with the `mpg` __data frame__ found in ggplot2 (aka `ggplot2::mpg`). A data frame is a rectangular collection of variables (in the columns) and observations (in the rows). `mpg` contains observations collected by the US Environment Protection Agency on 38 models of car.
You can test your answer with the `mpg` __data frame__ found in ggplot2 (aka `ggplot2::mpg`). A data frame is a rectangular collection of variables (in the columns) and observations (in the rows). `mpg` contains observations collected by the US Environmental Protection Agency on 38 models of car.
```{r}
mpg
@ -67,7 +67,7 @@ With ggplot2, you begin a plot with the function `ggplot()`. `ggplot()` creates
You complete your graph by adding one or more layers to `ggplot()`. The function `geom_point()` adds a layer of points to your plot, which creates a scatterplot. ggplot2 comes with many geom functions that each add a different type of layer to a plot. You'll learn a whole bunch of them throughout this chapter.
Each geom function in ggplot2 takes a `mapping` argument. This defines how variables in your dataset are mapped to visual properties. The `mapping` argument is always paired with `aes()`, and the `x` and `y` arguments of `aes()` specify which variables to map to the x and y axes. ggplot2 looks for the mapped variable in the `data` argument, in this case, `mpg`.
Each geom function in ggplot2 takes a `mapping` argument. This defines how variables in your dataset are mapped to visual properties. The `mapping` argument is always paired with `aes()`, and the `x` and `y` arguments of `aes()` specify which variables to map to the x and y axes. ggplot2 looks for the mapped variables in the `data` argument, in this case, `mpg`.
### A graphing template
@ -142,7 +142,7 @@ ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, size = class))
```
Or we could have mapped `class` to the _alpha_ aesthetic, which controls the transparency of the points, or the shape of the points.
Or we could have mapped `class` to the _alpha_ aesthetic, which controls the transparency of the points, or to the shape aesthetic, which controls the shape of the points.
```{r out.width = "50%", fig.align = 'default', warning = FALSE, fig.asp = 1/2, fig.cap =""}
# Left
@ -215,7 +215,7 @@ ggplot(shapes, aes(x, y)) +
(Hint: use `?geom_point`)
1. What happens if you map an aesthetic to something other than a variable
name, like `aes(colour = displ < 5)`?
name, like `aes(colour = displ < 5)`? Note, you'll also need to specify x and y.
## Common problems
@ -344,7 +344,7 @@ ggplot(data = mpg, mapping = aes(x = displ, y = hwy, color = drv)) +
geom_smooth(mapping = aes(linetype = drv))
```
Notice that this plot contains two geoms in the same graph! If this makes you excited, buckle up. In the next section, we will learn how to place multiple geoms in the same plot.
Notice that this plot contains two geoms in the same graph! If this makes you excited, buckle up. We will learn how to place multiple geoms in the same plot very soon.
ggplot2 provides over 30 geoms, and extension packages provide even more (see <https://www.ggplot2-exts.org> for a sampling). The best way to get a comprehensive overview is the ggplot2 cheatsheet, which you can find at <http://rstudio.com/cheatsheets>. To learn more about any single geom, use help: `?geom_smooth`.
@ -396,7 +396,7 @@ ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
geom_smooth(data = filter(mpg, class == "subcompact"), se = FALSE)
```
(You'll learn how `filter()` works in the next chapter: for now, just know that this command selects only the subcompact cars.)
(You'll learn how `filter()` works in the chapter on data transformations: for now, just know that this command selects only the subcompact cars.)
### Exercises