diff --git a/README.md b/README.md index b22056a..117867b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ devtools::install_github("hadley/r4ds") ``` #| echo: FALSE #| out.width: NULL - #| fig.retina: 1.5 knitr::include_graphics("diagrams/transform.png", dpi = 270) ## Code of Conduct diff --git a/data-tidy.Rmd b/data-tidy.Rmd index 9392522..4c1f375 100644 --- a/data-tidy.Rmd +++ b/data-tidy.Rmd @@ -50,7 +50,9 @@ There are three interrelated rules that make a dataset tidy: Figure \@ref(fig:tidy-structure) shows the rules visually. -```{r tidy-structure, echo = FALSE, out.width = "100%"} +```{r tidy-structure} +#| echo: FALSE +#| out.width: NULL #| fig.cap: > #| Following three rules makes a dataset tidy: variables are columns, #| observations are rows, and values are cells. @@ -59,7 +61,7 @@ Figure \@ref(fig:tidy-structure) shows the rules visually. #| shows that each variable is column. The second panel shows that each #| observation is a row. The third panel shows that each value is #| a cell. -knitr::include_graphics("images/tidy-1.png") +knitr::include_graphics("images/tidy-1.png", dpi = 270) ``` Why ensure that your data is tidy? @@ -259,23 +261,23 @@ It's easier to see if we take it component by component. Columns that are already variables need to be repeated, once for each column in `cols`, as shown in Figure \@ref(fig:pivot-variables). ```{r pivot-variables} -#| echo: false -#| out.width: ~ +#| echo: FALSE +#| out.width: NULL #| fig.cap: > #| Columns that are already variables need to be repeated, once for #| each column that is pivotted. -knitr::include_graphics("diagrams/tidy-data/variables.png", dpi = 144) +knitr::include_graphics("diagrams/tidy-data/variables.png", dpi = 270) ``` The column names become values in a new variable, whose name is given by `names_to`, as shown in Figure \@ref(fig:pivot-names). They need to be repeated for each row in the original dataset. ```{r pivot-names} -#| echo: false -#| out.width: ~ +#| echo: FALSE +#| out.width: NULL #| fig.cap: > #| The column names of pivoted columns become a new column. -knitr::include_graphics("diagrams/tidy-data/column-names.png", dpi = 144) +knitr::include_graphics("diagrams/tidy-data/column-names.png", dpi = 270) ``` The cell values also become values in a new variable, with name given by `values_to`. @@ -283,12 +285,12 @@ The are unwound row by row. Figure \@ref(fig:pivot-values) illustrates the process. ```{r pivot-values} -#| echo: false -#| out.width: ~ +#| echo: FALSE +#| out.width: NULL #| fig.cap: > #| The number of values are preserved (not repeated), but unwound #| row-by-row. -knitr::include_graphics("diagrams/tidy-data/cell-values.png", dpi = 144) +knitr::include_graphics("diagrams/tidy-data/cell-values.png", dpi = 270) ``` ### Many variables in column names @@ -328,7 +330,7 @@ The next step up in complexity is when the column names include a mix of variabl For example, take the `household` dataset: ```{r} -family +household ``` This dataset contains data about five families, with the names and dates of birth of up to two children. diff --git a/diagrams/tidy-data/cell-values.png b/diagrams/tidy-data/cell-values.png index 71bd640..dc8edc4 100644 Binary files a/diagrams/tidy-data/cell-values.png and b/diagrams/tidy-data/cell-values.png differ diff --git a/diagrams/tidy-data/column-names.png b/diagrams/tidy-data/column-names.png index b33a16f..1e8ccb6 100644 Binary files a/diagrams/tidy-data/column-names.png and b/diagrams/tidy-data/column-names.png differ diff --git a/diagrams/tidy-data/variables.png b/diagrams/tidy-data/variables.png index dcbf166..5f14aa1 100644 Binary files a/diagrams/tidy-data/variables.png and b/diagrams/tidy-data/variables.png differ