diff --git a/_quarto.yml b/_quarto.yml index 983ad4a..4768ee9 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -12,8 +12,8 @@ book: Çetinkaya-Rundel, and Garrett Grolemund. right: | This book was built with Quarto. - cover-image: cover.png - favicon: cover.png + cover-image: cover.jpg + favicon: cover.jpg site-url: https://r4ds.hadley.nz/ repo-url: https://github.com/hadley/r4ds/ repo-branch: main diff --git a/cover.jpg b/cover.jpg new file mode 100644 index 0000000..fbe1bff Binary files /dev/null and b/cover.jpg differ diff --git a/cover.png b/cover.png deleted file mode 100644 index a7150bd..0000000 Binary files a/cover.png and /dev/null differ diff --git a/data-tidy.qmd b/data-tidy.qmd index 6ecb267..f637762 100644 --- a/data-tidy.qmd +++ b/data-tidy.qmd @@ -350,7 +350,7 @@ There are two columns that are already variables and are easy to interpret: `cou They are followed by 56 columns like `sp_m_014`, `ep_m_4554`, and `rel_m_3544`. If you stare at these columns for long enough, you'll notice there's a pattern. Each column name is made up of three pieces separated by `_`. -The first piece, `sp`/`rel`/`ep`, describes the method used for the diagnosis, the second piece, `m`/`f` is the `gender` (coded as a binary variable in this dataset), and the third piece, `014`/`1524`/`2534`/`3544`/`4554`/``` 5564/``65 ``` is the `age` range (`014` represents 0-14, for example). +The first piece, `sp`/`rel`/`ep`, describes the method used for the diagnosis, the second piece, `m`/`f` is the `gender` (coded as a binary variable in this dataset), and the third piece, `014`/`1524`/`2534`/`3544`/`4554`/`5564`/`65` is the `age` range (`014` represents 0-14, for example). So in this case we have six pieces of information recorded in `who2`: the country and the year (already columns); the method of diagnosis, the gender category, and the age range category (contained in the other column names); and the count of patients in that category (cell values). To organize these six pieces of information in six separate columns, we use `pivot_longer()` with a vector of column names for `names_to` and instructors for splitting the original variable names into pieces for `names_sep` as well as a column name for `values_to`: @@ -422,15 +422,15 @@ When you use `".value"` in `names_to`, the column names in the input contribute #| label: fig-pivot-names-and-values #| echo: false #| fig-cap: > -#| Pivoting with `names_to = c(".value", "id")` splits the column names +#| Pivoting with `names_to = c(".value", "num")` splits the column names #| into two components: the first part determines the output column #| name (`x` or `y`), and the second part determines the value of the -#| `id` column. +#| `num` column. #| fig-alt: > #| A diagram that uses color to illustrate how the special ".value" #| sentinel works. The input has names "x_1", "x_2", "y_1", and "y_2", #| and we want to use the first component ("x", "y") as a variable name -#| and the second ("1", "2") as the value for a new "id" column. +#| and the second ("1", "2") as the value for a new "num" column. knitr::include_graphics("diagrams/tidy-data/names-and-values.png", dpi = 270) ``` diff --git a/diagrams/tidy-data.graffle b/diagrams/tidy-data.graffle index 6e8a605..f394d3a 100644 Binary files a/diagrams/tidy-data.graffle and b/diagrams/tidy-data.graffle differ diff --git a/diagrams/tidy-data/names-and-values.png b/diagrams/tidy-data/names-and-values.png index 307efc5..b17416e 100644 Binary files a/diagrams/tidy-data/names-and-values.png and b/diagrams/tidy-data/names-and-values.png differ diff --git a/numbers.qmd b/numbers.qmd index e4cda19..3c2684a 100644 --- a/numbers.qmd +++ b/numbers.qmd @@ -373,7 +373,7 @@ x <- 1:10 cumsum(x) ``` -If you need more complex rolling or sliding aggregates, try the [slider](https://slider.r-lib.org/) package by Davis Vaughan. +If you need more complex rolling or sliding aggregates, try the [slider](https://slider.r-lib.org/) package. ### Exercises diff --git a/quarto-formats.qmd b/quarto-formats.qmd index 7488d71..49f3b0e 100644 --- a/quarto-formats.qmd +++ b/quarto-formats.qmd @@ -245,7 +245,7 @@ cat(readr::read_file("quarto/example-book.yml")) ``` We recommend that you use an RStudio project for your websites and books. -Based on the `_quarto.yml` file, RStudio will recognize the type of project you're working on, and add a Built tab to the IDE that you can use to render and preview your websites and books. +Based on the `_quarto.yml` file, RStudio will recognize the type of project you're working on, and add a Build tab to the IDE that you can use to render and preview your websites and books. Both websites and books can also be rendered using `quarto::render()`. Read more at about Quarto websites and about books.