Fix figure manipulation
This commit is contained in:
@@ -97,8 +97,8 @@ table4b # population
|
||||
<div class="cell">
|
||||
<div class="cell-output-display">
|
||||
|
||||
<figure id="fig-pivot-names-and-values"><p><img src="images/tidy-1.png" alt="Three panels, each representing a tidy data frame. The first panel shows that each variable is a column. The second panel shows that each observation is a row. The third panel shows that each value is a cell." width="683"/></p>
|
||||
<figcaption>Figure 6.1: The following three rules make a dataset tidy: variables are columns, observations are rows, and values are cells.</figcaption>
|
||||
<figure id="fig-tidy-structure"><p><img src="images/tidy-1.png" alt="Three panels, each representing a tidy data frame. The first panel shows that each variable is a column. The second panel shows that each observation is a row. The third panel shows that each value is a cell." width="683"/></p>
|
||||
<figcaption>The following three rules make a dataset tidy: variables are columns, observations are rows, and values are cells.</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
@@ -274,8 +274,8 @@ billboard_tidy
|
||||
scale_y_reverse()</pre>
|
||||
<div class="cell-output-display">
|
||||
|
||||
<figure class="figure"><p><img src="data-tidy_files/figure-html/fig-billboard-ranks-1.png" alt="A line plot with week on the x-axis and rank on the y-axis, where each line represents a song. Most songs appear to start at a high rank, rapidly accelerate to a low rank, and then decay again. There are suprisingly few tracks in the region when week is >20 and rank is >50." width="576"/></p>
|
||||
<figcaption class="figure-caption">Figure 6.2: A line plot showing how the rank of a song changes over time.</figcaption>
|
||||
<figure id="fig-billboard-ranks"><p><img src="data-tidy_files/figure-html/fig-billboard-ranks-1.png" alt="A line plot with week on the x-axis and rank on the y-axis, where each line represents a song. Most songs appear to start at a high rank, rapidly accelerate to a low rank, and then decay again. There are suprisingly few tracks in the region when week is >20 and rank is >50." width="576"/></p>
|
||||
<figcaption>A line plot showing how the rank of a song changes over time.</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
@@ -315,8 +315,8 @@ How does pivoting work?</h2>
|
||||
<div class="cell">
|
||||
<div class="cell-output-display">
|
||||
|
||||
<figure class="figure"><p><img src="diagrams/tidy-data/variables.png" alt="A diagram showing how `pivot_longer()` transforms a simple dataset, using color to highlight how the values in the `var` column ("A", "B", "C") are each repeated twice in the output because there are two columns being pivotted ("col1" and "col2")." width="469"/></p>
|
||||
<figcaption class="figure-caption">Figure 6.3: Columns that are already variables need to be repeated, once for each column that is pivotted.</figcaption>
|
||||
<figure id="fig-pivot-variables"><p><img src="diagrams/tidy-data/variables.png" alt="A diagram showing how `pivot_longer()` transforms a simple dataset, using color to highlight how the values in the `var` column ("A", "B", "C") are each repeated twice in the output because there are two columns being pivotted ("col1" and "col2")." width="469"/></p>
|
||||
<figcaption>Columns that are already variables need to be repeated, once for each column that is pivotted.</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
@@ -324,8 +324,8 @@ How does pivoting work?</h2>
|
||||
<div class="cell">
|
||||
<div class="cell-output-display">
|
||||
|
||||
<figure class="figure"><p><img src="diagrams/tidy-data/column-names.png" alt="A diagram showing how `pivot_longer()` transforms a simple data set, using color to highlight how column names ("col1" and "col2") become the values in a new `var` column. They are repeated three times because there were three rows in the input." width="469"/></p>
|
||||
<figcaption class="figure-caption">Figure 6.4: The column names of pivoted columns become a new column.</figcaption>
|
||||
<figure id="fig-pivot-names"><p><img src="diagrams/tidy-data/column-names.png" alt="A diagram showing how `pivot_longer()` transforms a simple data set, using color to highlight how column names ("col1" and "col2") become the values in a new `var` column. They are repeated three times because there were three rows in the input." width="469"/></p>
|
||||
<figcaption>The column names of pivoted columns become a new column.</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
@@ -333,8 +333,8 @@ How does pivoting work?</h2>
|
||||
<div class="cell">
|
||||
<div class="cell-output-display">
|
||||
|
||||
<figure class="figure"><p><img src="diagrams/tidy-data/cell-values.png" alt="A diagram showing how `pivot_longer()` transforms data, using color to highlight how the cell values (the numbers 1 to 6) become the values in a new `value` column. They are unwound row-by-row, so the original rows (1,2), then (3,4), then (5,6), become a column running from 1 to 6." width="469"/></p>
|
||||
<figcaption class="figure-caption">Figure 6.5: The number of values is preserved (not repeated), but unwound row-by-row.</figcaption>
|
||||
<figure id="fig-pivot-values"><p><img src="diagrams/tidy-data/cell-values.png" alt="A diagram showing how `pivot_longer()` transforms data, using color to highlight how the cell values (the numbers 1 to 6) become the values in a new `value` column. They are unwound row-by-row, so the original rows (1,2), then (3,4), then (5,6), become a column running from 1 to 6." width="469"/></p>
|
||||
<figcaption>The number of values is preserved (not repeated), but unwound row-by-row.</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
@@ -389,8 +389,8 @@ Many variables in column names</h2>
|
||||
<div class="cell">
|
||||
<div class="cell-output-display">
|
||||
|
||||
<figure class="figure"><p><img src="diagrams/tidy-data/multiple-names.png" alt="A diagram that uses color to illustrate how supplying `names_sep` and multiple `names_to` creates multiple variables in the output. The input has variable names "x_1" and "y_2" which are split up by "_" to create name and number columns in the output. This is is similar case with a single `names_to`, but what would have been a single output variable is now separated into multiple variables." width="600"/></p>
|
||||
<figcaption class="figure-caption">Figure 6.6: Pivotting with many variables in the column names means that each column name now fills in values in multiple output columns.</figcaption>
|
||||
<figure id="fig-pivot-multiple-names"><p><img src="diagrams/tidy-data/multiple-names.png" alt="A diagram that uses color to illustrate how supplying `names_sep` and multiple `names_to` creates multiple variables in the output. The input has variable names "x_1" and "y_2" which are split up by "_" to create name and number columns in the output. This is is similar case with a single `names_to`, but what would have been a single output variable is now separated into multiple variables." width="600"/></p>
|
||||
<figcaption>Pivotting with many variables in the column names means that each column name now fills in values in multiple output columns.</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
@@ -439,8 +439,8 @@ Data and variable names in the column headers</h2>
|
||||
<div class="cell">
|
||||
<div class="cell-output-display">
|
||||
|
||||
<figure class="figure"><p><img src="diagrams/tidy-data/names-and-values.png" 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." width="540"/></p>
|
||||
<figcaption class="figure-caption">Figure 6.7: Pivoting with <code>names_to = c(".value", "id")</code> splits the column names into two components: the first part determines the output column name (<code>x</code> or <code>y</code>), and the second part determines the value of the <code>id</code> column.</figcaption>
|
||||
<figure id="fig-pivot-names-and-values"><p><img src="diagrams/tidy-data/names-and-values.png" 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." width="540"/></p>
|
||||
<figcaption>Pivoting with names_to = c(".value", "id") 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.<code>names_to = c(".value", "id")</code> splits the column names into two components: the first part determines the output column name (<code>x</code> or <code>y</code>), and the second part determines the value of the <code>id</code> column.</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user