From 712907fc753408047b625faf451e701b84b5f94d Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Fri, 14 May 2021 15:03:58 +0200 Subject: [PATCH] Fix typos (#950) --- data-import.Rmd | 2 +- data-visualize.Rmd | 2 +- datetimes.Rmd | 2 +- functions.Rmd | 4 ++-- iteration.Rmd | 2 +- vectors.Rmd | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data-import.Rmd b/data-import.Rmd index 7955995..5f8404f 100644 --- a/data-import.Rmd +++ b/data-import.Rmd @@ -498,7 +498,7 @@ readr contains a challenging CSV that illustrates both of these problems: challenge <- read_csv(readr_example("challenge.csv")) ``` -(Note the use of `readr_example()` which finds the path to one of the files included with the package) +(Note the use of `readr_example()` which finds the path to one of the files included with the package.) There are two printed outputs: the column specification generated by looking at the first 1000 rows, and the first five parsing failures. It's always a good idea to explicitly pull out the `problems()`, so you can explore them in more depth: diff --git a/data-visualize.Rmd b/data-visualize.Rmd index 0c0dd54..94ffa6f 100644 --- a/data-visualize.Rmd +++ b/data-visualize.Rmd @@ -309,7 +309,7 @@ One way to add additional variables is with aesthetics. Another way, particularly useful for categorical variables, is to split your plot into **facets**, subplots that each display one subset of the data. To facet your plot by a single variable, use `facet_wrap()`. -The first argument of `facet_wrap()` is a formula, which you create with `~` followed by a variable name (here "formula" is the bane if a data structure in R, not a synonym for "equation"). +The first argument of `facet_wrap()` is a formula, which you create with `~` followed by a variable name (here, "formula" is the bane if a data structure in R, not a synonym for "equation"). The variable that you pass to `facet_wrap()` should be discrete. ```{r, fig.alt = "Scatterplot of highway fuel efficiency versus engine size of cars in ggplot2::mpg, faceted by class, with facets spanning two rows."} diff --git a/datetimes.Rmd b/datetimes.Rmd index 75dcd9c..b12ed4a 100644 --- a/datetimes.Rmd +++ b/datetimes.Rmd @@ -564,7 +564,7 @@ Examples include "America/New_York", "Europe/Paris", and "Pacific/Auckland". You might wonder why the time zone uses a city, when typically you think of time zones as associated with a country or region within a country. This is because the IANA database has to record decades worth of time zone rules. In the course of decades, countries change names (or break apart) fairly frequently, but city names tend to stay the same. -Another problem is that name needs to reflect not only to the current behaviour, but also the complete history. +Another problem is that the name needs to reflect not only the current behaviour, but also the complete history. For example, there are time zones for both "America/New_York" and "America/Detroit". These cities both currently use Eastern Standard Time but in 1969-1972 Michigan (the state in which Detroit is located), did not follow DST, so it needs a different name. It's worth reading the raw time zone database (available at ) just to read some of these stories! diff --git a/functions.Rmd b/functions.Rmd index 2c19096..4b56f02 100644 --- a/functions.Rmd +++ b/functions.Rmd @@ -100,7 +100,7 @@ There are three key steps to creating a new function: Here we have just one argument. If we had more the call would look like `function(x, y, z)`. -3. You place the code you have developed in **body** of the function, a `{` block that immediately follows `function(...)`. +3. You place the code you have developed in the **body** of the function, a `{` block that immediately follows `function(...)`. Note the overall process: I only made the function after I'd figured out how to make it work with a simple input. It's easier to start with working code and turn it into a function; it's harder to create a function and then try to make it work. @@ -915,4 +915,4 @@ R places few limits on your power. You can do many things that you can't do in other programming languages. You can do many things that 99% of the time are extremely ill-advised (like overriding how addition works!). But this power and flexibility is what makes tools like ggplot2 and dplyr possible. -Learning how to make best use of this flexibility is beyond the scope of this book, but you can read about in [*Advanced R*](http://adv-r.had.co.nz). +Learning how to make best use of this flexibility is beyond the scope of this book, but you can read about it in [*Advanced R*](http://adv-r.had.co.nz). diff --git a/iteration.Rmd b/iteration.Rmd index dbdd2f2..726ac2f 100644 --- a/iteration.Rmd +++ b/iteration.Rmd @@ -214,7 +214,7 @@ There are two other forms: This is most useful if you only care about side-effects, like plotting or saving a file, because it's difficult to save the output efficiently. 2. Loop over the names: `for (nm in names(xs))`. - This gives you name, which you can use to access the value with `x[[nm]]`. + This gives you a name, which you can use to access the value with `x[[nm]]`. This is useful if you want to use the name in a plot title or a file name. If you're creating named output, make sure to name the results vector like so: diff --git a/vectors.Rmd b/vectors.Rmd index 54ef76b..a97eba3 100644 --- a/vectors.Rmd +++ b/vectors.Rmd @@ -410,7 +410,7 @@ The distinction between `[` and `[[` is most important for lists, as we'll see s 3. Compare and contrast `setNames()` with `purrr::set_names()`. -4. Create functions that take a vector as input and returns: +4. Create functions that take a vector as input and return: a. The last value. Should you use `[` or `[[`? b. The elements at even numbered positions. @@ -685,7 +685,7 @@ attributes(y) POSIXlts are rare inside the tidyverse. They do crop up in base R, because they are needed to extract specific components of a date, like the year or month. Since lubridate provides helpers for you to do this instead, you don't need them. -POSIXct's are always easier to work with, so if you find you have a POSIXlt, you should always convert it to a regular date time `lubridate::as_date_time()`. +POSIXct's are always easier to work with, so if you find you have a POSIXlt, you should always convert it to a regular date time with `lubridate::as_date_time()`. ### Tibbles