Skip to content

Commit 3d21973

Browse files
committed
fixed whitespace best I could for wrangling
1 parent 725797e commit 3d21973

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

intro.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ to read data into R.
260260

261261
(ref:img-read-csv) Syntax for the `read_csv` function.
262262

263-
``` {r img-read-csv, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:img-read-csv)", fig.retina = 2, out.width="100%", fig.pos = "H"}
263+
``` {r img-read-csv, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:img-read-csv)", fig.retina = 2, out.width="100%", fig.pos = "H", out.extra=""}
264264
image_read("img/read_csv_function.jpeg") |>
265265
image_crop("1625x1900")
266266
```
@@ -583,7 +583,7 @@ currently making it difficult to read the different language names.
583583
One solution is to rotate the plot such that the bars are horizontal rather than vertical.
584584
To accomplish this, we will swap the x and y coordinate axes:
585585

586-
```{r barplot-mother-tongue-flipped, fig.width=5, fig.height=3, fig.pos = "H", warning=FALSE, fig.cap = "Horizontal bar plot of the ten Aboriginal languages most often reported by Canadian residents as their mother tongue."}
586+
```{r barplot-mother-tongue-flipped, fig.width=5, fig.height=3, fig.pos = "H", out.extra="", warning=FALSE, fig.cap = "Horizontal bar plot of the ten Aboriginal languages most often reported by Canadian residents as their mother tongue."}
587587
ggplot(ten_lang, aes(x = mother_tongue, y = language)) +
588588
geom_bar(stat = "identity") +
589589
xlab("Mother Tongue (Number of Canadian Residents)") +

wrangling.Rmd

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,15 @@ these are the values that the three variables take for the first entity in the
8181
data set. There are 13 entities in the data set in total, corresponding to the
8282
13 rows in Figure \@ref(fig:02-obs).
8383

84-
``` {r 02-obs, echo = FALSE, message = FALSE, warning = FALSE, fig.align = "center", fig.cap = "A data frame storing data regarding the population of various regions in Canada. In this example data frame, the row that corresponds to the observation for the city of Vancouver is colored yellow, and the column that corresponds to the population variable is colored blue.", fig.retina = 2, out.width = "100%"}
84+
``` {r 02-obs, echo = FALSE, message = FALSE, warning = FALSE, fig.align = "center", fig.pos = "H", out.extra="", fig.cap = "A data frame storing data regarding the population of various regions in Canada. In this example data frame, the row that corresponds to the observation for the city of Vancouver is colored yellow, and the column that corresponds to the population variable is colored blue.", fig.retina = 2, out.width = "100%"}
8585
image_read("img/data_frame_slides_cdn/data_frame_slides_cdn.004.jpeg") %>%
8686
image_crop("3632x700")
8787
```
8888

89-
Internally, R stores the columns of a data frame as either
89+
R stores the columns of a data frame as either
9090
*lists* or *vectors*. For example, the data frame in Figure
9191
\@ref(fig:02-vectors) has three vectors whose names are `region`, `year` and
92-
`population`. We will explain what lists and vectors are in the next two
93-
sections.
92+
`population`. The next two sections will explain what lists and vectors are.
9493

9594
``` {r 02-vectors, echo = FALSE, message = FALSE, warning = FALSE, fig.align = "center", fig.cap = "Data frame with three vectors.", fig.retina = 2, out.width = "100%"}
9695
image_read("img/data_frame_slides_cdn/data_frame_slides_cdn.005.jpeg") %>%
@@ -129,6 +128,8 @@ image_read("img/data_frame_slides_cdn/data_frame_slides_cdn.007.jpeg") %>%
129128
image_crop("3632x590")
130129
```
131130

131+
\newpage
132+
132133
Table: (#tab:datatype-table) Basic data types in R
133134

134135
| Data type | Abbreviation | Description | Example |
@@ -467,7 +468,7 @@ in the `pivot_wider` function.
467468

468469
(ref:img-pivot-wider) Syntax for the `pivot_wider` function.
469470

470-
``` {r img-pivot-wider, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:img-pivot-wider)", fig.retina = 2, out.width="100%"}
471+
``` {r img-pivot-wider, echo = FALSE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.cap = "(ref:img-pivot-wider)", fig.retina = 2, out.width="100%"}
471472
image_read("img/pivot_wider.jpeg") |>
472473
image_crop("1625x850")
473474
```
@@ -541,7 +542,7 @@ outlines what we need to specify to use `separate`.
541542

542543
(ref:img-separate) Syntax for the `separate` function.
543544

544-
``` {r img-separate, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:img-separate)", fig.retina = 2, out.width = "100%"}
545+
``` {r img-separate, echo = FALSE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.cap = "(ref:img-separate)", fig.retina = 2, out.width = "100%"}
545546
image_read("img/separate_function.jpeg") |>
546547
image_crop("1625x1900")
547548
```
@@ -774,8 +775,6 @@ five_cities <- filter(region_data,
774775
five_cities
775776
```
776777

777-
\newpage
778-
779778
> **Note:** What's the difference between `==` and `%in%`? Suppose we have two
780779
> vectors, `vectorA` and `vectorB`. If you type `vectorA == vectorB` into R it
781780
> will compare the vectors element by element. R checks if the first element of
@@ -867,7 +866,7 @@ then `mutate` would create new columns with the names we specified.
867866

868867
(ref:img-mutate) Syntax for the `mutate` function.
869868

870-
``` {r img-mutate, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:img-mutate)", fig.retina = 2, out.width = "100%"}
869+
``` {r img-mutate, echo = FALSE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.cap = "(ref:img-mutate)", fig.retina = 2, out.width = "100%"}
871870
image_read("img/mutate_function.jpeg") |>
872871
image_crop("1625x1900")
873872
```
@@ -1205,7 +1204,7 @@ or columns, as shown in Figure \@ref(fig:summarize).
12051204

12061205
(ref:summarize) `summarize` is useful for calculating summary statistics on one or more column(s). In its simplest use case, it creates a new data frame with a single row containing the summary statistic(s) for each column being summarized. The darker, top row of each table represents the column headers.
12071206

1208-
```{r summarize, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:summarize)", fig.retina = 2, out.width = "100%"}
1207+
```{r summarize, echo = FALSE, message = FALSE, warning = FALSE, fig.align = "center", fig.cap = "(ref:summarize)", fig.retina = 2, out.width = "85%"}
12091208
image_read("img/summarize/summarize.001.jpeg") |>
12101209
image_crop("2000x475+0+300")
12111210
```
@@ -1303,7 +1302,7 @@ for each of the regions in the data set.
13031302

13041303
(ref:summarize-groupby) `summarize` and `group_by` is useful for calculating summary statistics on one or more column(s) for each group. It creates a new data frame&mdash;with one row for each group&mdash;containing the summary statistic(s) for each column being summarized. It also creates a column listing the value of the grouping variable. The darker, top row of each table represents the column headers. The gray, blue, and green colored rows correspond to the rows that belong to each of the three groups being represented in this cartoon example.
13051304

1306-
```{r summarize-groupby, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:summarize-groupby)", fig.retina = 2, out.width = "100%"}
1305+
```{r summarize-groupby, echo = FALSE, message = FALSE, warning = FALSE, fig.align = "center", fig.cap = "(ref:summarize-groupby)", fig.retina = 2, out.width = "85%"}
13071306
image_read("img/summarize/summarize.002.jpeg") |>
13081307
image_crop("2000x475+0+300")
13091308
```
@@ -1345,7 +1344,7 @@ Then we will also explore how we can use a more general iteration function,
13451344

13461345
(ref:summarize-across) `summarize` + `across` or `map` is useful for efficiently calculating summary statistics on many columns at once. The darker, top row of each table represents the column headers.
13471346

1348-
```{r summarize-across, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:summarize-across)", fig.retina = 2, out.width = "100%"}
1347+
```{r summarize-across, echo = FALSE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.align = "center", fig.cap = "(ref:summarize-across)", fig.retina = 2, out.width = "85%"}
13491348
image_read("img/summarize/summarize.003.jpeg") |>
13501349
image_crop("2000x475+0+300")
13511350
```
@@ -1449,8 +1448,6 @@ region_lang |>
14491448
map_dfr(max)
14501449
```
14511450

1452-
\newpage
1453-
14541451
> **Note:** Similar to when we use base R statistical summary functions
14551452
> (e.g., `max`, `min`, `mean`, `sum`, etc.) with `summarize`,
14561453
> `map` functions paired with base R statistical summary functions
@@ -1483,7 +1480,7 @@ We illustrate such a data transformation in Figure \@ref(fig:mutate-across).
14831480
14841481
(ref:mutate-across) `mutate` and `across` is useful for applying functions across many columns. The darker, top row of each table represents the column headers.
14851482
1486-
```{r mutate-across, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:mutate-across)", fig.retina = 2, out.width = "100%"}
1483+
```{r mutate-across, echo = FALSE, message = FALSE, warning = FALSE, fig.align = "center", fig.cap = "(ref:mutate-across)", fig.retina = 2, out.width = "85%"}
14871484
image_read("img/summarize/summarize.005.jpeg") |>
14881485
image_crop("2000x475+0+300")
14891486
```
@@ -1525,7 +1522,7 @@ We illustrate such a data transformation in Figure \@ref(fig:rowwise).
15251522

15261523
(ref:rowwise) `rowwise` and `mutate` is useful for applying functions across columns within one row. The darker, top row of each table represents the column headers.
15271524

1528-
```{r rowwise, echo = FALSE, message = FALSE, warning = FALSE, fig.cap = "(ref:rowwise)", fig.retina = 2, out.width = "100%"}
1525+
```{r rowwise, echo = FALSE, message = FALSE, warning = FALSE, fig.align = "center", fig.cap = "(ref:rowwise)", fig.retina = 2, out.width = "85%"}
15291526
image_read("img/summarize/summarize.004.jpeg") |>
15301527
image_crop("2000x475+0+300")
15311528
```
@@ -1597,6 +1594,8 @@ functions we learned in this chapter. In the following chapters, you will
15971594
learn how you can take this tidy data and do so much more with it to answer your
15981595
burning data science questions!
15991596

1597+
\newpage
1598+
16001599
Table: (#tab:summary-functions-table) Summary of wrangling functions
16011600

16021601
| Function | Description |

0 commit comments

Comments
 (0)