Scatter around a few more explanations of ::

This commit is contained in:
hadley 2016-07-19 08:11:08 -05:00
parent 8faebedf9f
commit 51f8c2d8b5
3 changed files with 7 additions and 1 deletions

View File

@ -27,6 +27,8 @@ library(nycflights13)
library(dplyr)
```
We'll also use the `str_c()` function from stringr, but rather than loading the complete package just to access this one function, we'll use it as `stringr::str_c()`.
## nycflights13 {#nycflights13-relational}
You can use the nycflights13 package to learn about relational data. nycflights13 contains four data frames that are related to the `flights` table that you used in Data Transformation:

View File

@ -140,6 +140,8 @@ near(sqrt(2) ^ 2, 2)
near(1 / 49 * 49, 1)
```
(Remember that we use `::` to explicit about where a function lives. If dplyr is installed, `dplyr::near()` will always work. If you want to use the shorter `near()`, you need to make sure you have loaded dplyr with `library(dplyr)`.)
### Logical operators
Multiple arguments to `filter()` are combined with "and": every expression must be true in order for a row to be included in the output. For other types of combinations, you'll need to use Boolean operators yourself:

View File

@ -7,7 +7,7 @@ This chapter will teach you how to visualize your data with R and ggplot2. R con
## Prerequisites
To access the datasets, help pages, and functions that we will use in this chapter, load ggplot2. We'll also load tibble, which you'll learn about later. It improves the default printing of datasets.
To access the datasets, help pages, and functions that we will use in this chapter, load ggplot2 using the `library()` function. We'll also load tibble, which you'll learn about later. It improves the default printing of datasets.
```{r setup}
library(ggplot2)
@ -23,6 +23,8 @@ library(ggplot2)
You only need to install a package once, but you need to reload it every time you start a new session.
If we need to be explicit about where a function (or dataset) comes from, we'll use the special form `package::function()`. For example, `ggplot2::ggplot()` tells you explicitly that we're using the `ggplot()` function from the ggplot2 package.
## A graphing template
Let's use our first graph to answer a question: Do cars with big engines use more fuel than cars with small engines? You probably already have an answer, but try to make your answer precise. What does the relationship between engine size and fuel efficiency look like? Is it positive? Negative? Linear? Nonlinear?