File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed
Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -186,8 +186,8 @@ parameter "variables_only = T".
186186What kind of values can the individual datapoints take?
187187
188188``` {r get-values}
189- metadata %>%
190- slice(4) %>%
189+ metadata |>
190+ slice(4) |>
191191 pull(values)
192192```
193193
@@ -198,11 +198,11 @@ column.
198198The same trick can be done for the other fields in the table:
199199
200200``` {r municipalites}
201- metadata %>%
202- slice(1) %>%
203- pull(values) %>%
204- .[[1]] %>%
205- head
201+ metadata |>
202+ slice(1) |>
203+ pull(values) |>
204+ .[[1]] |>
205+ head()
206206```
207207Here we see the individual municipalities in Denmark.
208208
@@ -249,8 +249,8 @@ That information is stored in the variable "CIVILSTAND".
249249
250250And above, we saw that we had the following values in that variable:
251251``` {r pulling-values}
252- metadata %>%
253- slice(4) %>%
252+ metadata |>
253+ slice(4) |>
254254 pull(values)
255255```
256256
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ specify the result that we want:
155155
156156``` {r specific-joke}
157157library(tidyverse)
158- GET("https://icanhazdadjoke.com/j/lGJmrrzAsc", accept("text/plain")) %>%
158+ GET("https://icanhazdadjoke.com/j/lGJmrrzAsc", accept("text/plain")) |>
159159 content()
160160```
161161
@@ -174,7 +174,7 @@ it to *result*:
174174
175175``` {r dog-jokes}
176176result <- GET("https://icanhazdadjoke.com/search?term=dog",
177- accept("application/json")) %>%
177+ accept("application/json")) |>
178178 content()
179179result
180180```
@@ -188,8 +188,8 @@ convert it to a data frame. We begin by loading the library:
188188
189189``` {r extract-from-json}
190190library(jsonlite)
191- GET("https://icanhazdadjoke.com/search?term=dog", accept("application/json")) %>%
192- content(as="text") %>%
191+ GET("https://icanhazdadjoke.com/search?term=dog", accept("application/json")) |>
192+ content(as="text") |>
193193 fromJSON()
194194```
195195
@@ -215,8 +215,8 @@ Request dad jokes about cats
215215## Solution
216216
217217``` {r}
218- GET("https://icanhazdadjoke.com/search?term=dog", accept("application/json")) %>%
219- content(as="text") %>%
218+ GET("https://icanhazdadjoke.com/search?term=dog", accept("application/json")) |>
219+ content(as="text") |>
220220fromJSON()
221221```
222222
You can’t perform that action at this time.
0 commit comments