diff --git a/lists.Rmd b/lists.Rmd index 525988f..cfa0efa 100644 --- a/lists.Rmd +++ b/lists.Rmd @@ -80,7 +80,7 @@ x3 <- list(1, list(2, list(3))) I draw them as follows: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "75%"} knitr::include_graphics("diagrams/lists-structure.png") ``` @@ -129,7 +129,7 @@ a <- list(a = 1:3, b = "a string", c = pi, d = list(-1, -5)) Or visually: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "75%"} knitr::include_graphics("diagrams/lists-subsetting.png") ``` @@ -137,13 +137,13 @@ knitr::include_graphics("diagrams/lists-subsetting.png") It's easy to get confused between `[` and `[[`, but it's important to understand the difference. A few months ago I stayed at a hotel with a pretty interesting pepper shaker that I hope will help remember these differences: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "25%"} knitr::include_graphics("images/pepper.jpg") ``` If this pepper shaker is your list `x`, then, `x[1]` is a pepper shaker containing a single pepper packet: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "25%"} knitr::include_graphics("images/pepper-1.jpg") ``` @@ -151,13 +151,13 @@ knitr::include_graphics("images/pepper-1.jpg") `x[[1]]` is: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "25%"} knitr::include_graphics("images/pepper-2.jpg") ``` If you wanted to get the content of the pepper package, you'd need `x[[1]][[1]]`: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "25%"} knitr::include_graphics("images/pepper-3.jpg") ``` @@ -533,7 +533,7 @@ x %>% transpose() %>% str() Graphically, this looks like: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "75%"} knitr::include_graphics("diagrams/lists-transpose.png") ``` @@ -644,7 +644,7 @@ map2(mu, sigma, rnorm, n = 10) `map2()` generates this series of function calls: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "75%"} knitr::include_graphics("diagrams/lists-map2.png") ``` @@ -672,7 +672,7 @@ args1 %>% pmap(rnorm) %>% str() That looks like: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "75%"} knitr::include_graphics("diagrams/lists-pmap-unnamed.png") ``` @@ -685,7 +685,7 @@ args2 %>% pmap(rnorm) %>% str() That generates longer, but safer, calls: -```{r, echo = FALSE} +```{r, echo = FALSE, out.width = "75%"} knitr::include_graphics("diagrams/lists-pmap-named.png") ```