Skip to content

Commit 3767bda

Browse files
author
Susan Vanderplas
committed
Remove !expr F/T
1 parent 4d72259 commit 3767bda

File tree

8 files changed

+71
-72
lines changed

8 files changed

+71
-72
lines changed

part-advanced-topics/03-web-scraping.qmd

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Web Scraping {#sec-data-web}
22

33
```{r}
4-
#| include: !expr F
4+
#| include: false
55
knitr::knit_engines$set(html = function(options) {
66
code <- paste(options$code, collapse = '\n')
77
out <- ""
@@ -234,13 +234,13 @@ The city then included some small grocery stores that are very close to meeting
234234
We can [download the KML file](https://opendata.dc.gov/api/download/v1/items/1d7c9d0e3aac49c1aa88d377a3bae430/kml?layers=4) and change the extension to XML so that the file opens in a standard web browser, or we can directly download the KML file as an XML file as in the code chunk below.
235235

236236
```{r}
237-
#| include: !expr F
237+
#| include: false
238238
options(width = 120)
239239
```
240240

241241
```{r}
242242
#| label: get-dc-grocery-data
243-
#| error: !expr T
243+
#| error: true
244244
url <- "https://opendata.dc.gov/api/download/v1/items/1d7c9d0e3aac49c1aa88d377a3bae430/kml?layers=4"
245245
filename <- "../data/DC_Grocery_Stores_2025.xml"
246246
@@ -254,15 +254,15 @@ xml_tbl <- data.frame(line = 1:length(xml_text),
254254
```
255255

256256
```{r}
257-
#| echo: !expr F
257+
#| echo: false
258258
#| paged-print: true
259259
260260
DT::datatable(xml_tbl[c(1:10, 35:64, 3145:3151),], rownames = F, escape = 2, editable = F, options = list(searching = F))
261261
```
262262

263263

264264
```{r}
265-
#| include: !expr F
265+
#| include: false
266266
options(width = 80)
267267
```
268268

@@ -399,7 +399,7 @@ HTML:
399399

400400
Rendered:
401401
```{r}
402-
#| echo: !expr F
402+
#| echo: false
403403
htmltools::knit_print.html("<table><tr><th>Heading Col 1</th><th>Heading Col 2</th></tr><tr><td>Value 1</td><td>Value 2</td></tr></table>")
404404
```
405405

@@ -1332,8 +1332,8 @@ rev_war_battles2 <- tibble(
13321332
When writing custom functions for web scrapign, it's usually helpful to give yourself an idea of what the function does in a comment -- you can often reuse these functions, but that only works if you're kind to future you and remind yourself what they actually do.
13331333

13341334
```{r}
1335-
#| eval: !expr F
1336-
#| include: !expr F
1335+
#| eval: false
1336+
#| include: false
13371337
saveRDS(rev_war_battles2, "../data/rev-war-battles2.RDS")
13381338
```
13391339
```{r}
@@ -1344,7 +1344,7 @@ head(rev_war_battles2)
13441344

13451345

13461346
```{r}
1347-
#| eval: !expr F
1347+
#| eval: false
13481348
library(purrr)
13491349
13501350
process_battle_row <- function(node){# <1>
@@ -1365,8 +1365,8 @@ rev_war_battles3 <- map(rev_war_rows, process_battle_row) |> bind_rows() # <4>
13651365
4. Call `process_battle_row` on each row and bind the rows together.
13661366

13671367
```{r}
1368-
#| eval: !expr F
1369-
#| include: !expr F
1368+
#| eval: false
1369+
#| include: false
13701370
saveRDS(rev_war_battles3, "../data/rev-war-battles3.RDS")
13711371
```
13721372
```{r}
@@ -1476,7 +1476,7 @@ If the structured table doesn't exist, the location row doesn't exist, or there
14761476
##### R {-}
14771477

14781478
```{r}
1479-
#| eval: !expr F
1479+
#| eval: false
14801480
library(tidyr)
14811481
library(tibble)
14821482
@@ -1516,8 +1516,8 @@ battle_locations <- purrr::map(rev_war_battles2$link, get_battle_location)
15161516
battle_locations <- bind_rows(battle_locations)
15171517
```
15181518
```{r}
1519-
#| include: !expr F
1520-
#| eval: !expr F
1519+
#| include: false
1520+
#| eval: false
15211521
saveRDS(battle_locations, file = "../data/rev_war_battle_locations.RDS")
15221522
```
15231523
```{r}
@@ -1999,7 +1999,7 @@ team_data_clean <- map(team_data, clean_team_df) |>
19991999

20002000
##### Python {-}
20012001
```{python}
2002-
#| cache: !expr F
2002+
#| cache: false
20032003
from warnings import warn
20042004
20052005
def get_players(sub_df):

part-advanced-topics/04-xml-json-list-processing.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# Record-based Data and List Processing Strategies {#sec-xml}
2+
# Record-based Data and List Processing Strategies {#sec-record-data}
33

44
@sec-data-web introduces how XML and HTML documents are constructed and demonstrates different techniques for scraping data from the web.
55
@sec-data-apis introduces Application Programming Interfaces (APIs) to get data from the web in a cleaner, more efficient way.

part-advanced-topics/06-pdf-tools.qmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ You can also run `tesseract` from the command line, if you [install the library]
262262
For the sake of shorter commands, let's assume I'm working with a 1-page PDF file named `file.pdf` and want to create `file.txt` which contains the text of the image-based PDF.
263263

264264
```{bash}
265-
#| eval: !expr F
265+
#| eval: false
266266
pdftoppm -png ../data/file.pdf file # <1>
267267
tesseract -l eng ../data/file-1.png ../data/file-1-bash # <2>
268268
```
@@ -415,7 +415,7 @@ In any case, it's possible to use this command within R or Python, but once you
415415
Let's OCR the Lancaster county, NE home appraisal image PDF and see what we come up with.
416416

417417
```{bash}
418-
#| eval: !expr F
418+
#| eval: false
419419
ocrmypdf -l eng ../data/file.pdf ../data/file-ocrmypdf.pdf
420420
```
421421

@@ -851,7 +851,7 @@ There's a function, `locate_areas()`, that works interactively - it opens a view
851851
`locate_areas` provides a sequence of coordinates that are relatively consistent across multiple full-page tables, so we might try to use those coordinates to improve our table parsing.
852852

853853
```{r}
854-
#| eval: !expr F
854+
#| eval: false
855855
locate_areas(files[1], pages = rep(page_numbers[1], 5))
856856
```
857857

part-advanced-topics/07-intro-interactive-graphics.qmd

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ We'll demonstrate plotly's capabilities using the `volcanoes` data from [Tidy Tu
5656

5757
```{r}
5858
#| label: volcano-data-setup-r
59-
#| message: !expr F
60-
#| warning: !expr F
59+
#| message: false
60+
#| warning: false
6161
if (!"plotly" %in% installed.packages())
6262
install.packages("plotly")
6363
@@ -180,7 +180,7 @@ pl.io.write_html(fig, file = file, auto_open = False)
180180
```
181181

182182
```{r}
183-
#| echo: !expr F
183+
#| echo: false
184184
htmltools::includeHTML(py$file)
185185
```
186186

@@ -240,7 +240,7 @@ file = 'plotly-python/distplot-volcano.html'
240240
pl.io.write_html(fig, file = file, auto_open = False)
241241
```
242242
```{r}
243-
#| echo: !expr F
243+
#| echo: false
244244
library(reticulate)
245245
htmltools::includeHTML(py$file)
246246
```
@@ -572,7 +572,7 @@ pl.io.write_html(fig, file = file, auto_open = False)
572572
```
573573

574574
```{r}
575-
#| echo: !expr F
575+
#| echo: false
576576
htmltools::includeHTML(py$file)
577577
```
578578

@@ -588,7 +588,7 @@ file = 'plotly-python/vei-volcano.html'
588588
pl.io.write_html(fig, file = file, auto_open = False)
589589
```
590590
```{r}
591-
#| echo: !expr F
591+
#| echo: false
592592
htmltools::includeHTML(py$file)
593593
```
594594

@@ -606,7 +606,7 @@ file = 'plotly-python/vei-duration-volcano.html'
606606
pl.io.write_html(fig, file = file, auto_open = False)
607607
```
608608
```{r}
609-
#| echo: !expr F
609+
#| echo: false
610610
htmltools::includeHTML(py$file)
611611
```
612612

@@ -640,7 +640,7 @@ file = 'plotly-python/scatter-volcano.html'
640640
pl.io.write_html(fig, file = file, auto_open = False)
641641
```
642642
```{r}
643-
#| echo: !expr F
643+
#| echo: false
644644
htmltools::includeHTML(py$file)
645645
```
646646
:::
@@ -677,7 +677,7 @@ file = 'plotly-python/scatter-hover-volcano.html'
677677
pl.io.write_html(fig, file = file, auto_open = False)
678678
```
679679
```{r}
680-
#| echo: !expr F
680+
#| echo: false
681681
htmltools::includeHTML(py$file)
682682
```
683683

@@ -733,7 +733,7 @@ file = 'plotly-python/scatter-hover-update-volcano.html'
733733
pl.io.write_html(fig, file = file, auto_open = False)
734734
```
735735
```{r}
736-
#| echo: !expr F
736+
#| echo: false
737737
htmltools::includeHTML(py$file)
738738
```
739739
:::
@@ -842,7 +842,7 @@ To explore the leaflet package, we'll start out playing with a [dataset of Bigfo
842842

843843
```{r}
844844
#| label: leaflet-setup
845-
#| echo: !expr F
845+
#| echo: false
846846
if (!"leaflet" %in% installed.packages()) install.packages("leaflet")
847847
848848
library(leaflet)
@@ -852,7 +852,7 @@ bigfoot_data <- read_csv("https://query.data.world/s/egnaxxvegdkzzrhfhdh4izb6etm
852852
```
853853
```{r}
854854
#| label: leaflet-setup
855-
#| eval: !expr F
855+
#| eval: false
856856
```
857857

858858
We can start out by plotting a map with the location of each sighting. I've colored the points in a seasonal color scheme, and added the description of each incident as a mouseover label.
@@ -903,7 +903,7 @@ We can also plot regions, instead of just points. I downloaded a dataset release
903903

904904
I've set this chunk to not evaluate because it causes the book to be painfully large.
905905
```{r}
906-
#| eval: !expr F
906+
#| eval: false
907907
library(sf)
908908
bees <- st_read("../data/Crotch_s_Bumble_Bee_Range_-_CDFW_[ds3095].geojson")
909909
bees <- sf::st_transform(bees, 4326)

part-advanced-topics/08-javascript-graphics.qmd

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ We'll demonstrate plotly's capabilities using the `volcanoes` data from [Tidy Tu
5252

5353
```{r}
5454
#| label: volcano-data-setup-r
55-
#| message: !expr F
56-
#| warning: !expr F
55+
#| message: false
56+
#| warning: false
5757
if (!"plotly" %in% installed.packages())
5858
install.packages("plotly")
5959
@@ -176,7 +176,7 @@ pl.io.write_html(fig, file = file, auto_open = False)
176176
```
177177

178178
```{r}
179-
#| echo: !expr F
179+
#| echo: false
180180
htmltools::includeHTML(py$file)
181181
```
182182

@@ -236,7 +236,7 @@ file = 'plotly-python/distplot-volcano.html'
236236
pl.io.write_html(fig, file = file, auto_open = False)
237237
```
238238
```{r}
239-
#| echo: !expr F
239+
#| echo: false
240240
library(reticulate)
241241
htmltools::includeHTML(py$file)
242242
```
@@ -568,7 +568,7 @@ pl.io.write_html(fig, file = file, auto_open = False)
568568
```
569569

570570
```{r}
571-
#| echo: !expr F
571+
#| echo: false
572572
htmltools::includeHTML(py$file)
573573
```
574574

@@ -584,7 +584,7 @@ file = 'plotly-python/vei-volcano.html'
584584
pl.io.write_html(fig, file = file, auto_open = False)
585585
```
586586
```{r}
587-
#| echo: !expr F
587+
#| echo: false
588588
htmltools::includeHTML(py$file)
589589
```
590590

@@ -602,7 +602,7 @@ file = 'plotly-python/vei-duration-volcano.html'
602602
pl.io.write_html(fig, file = file, auto_open = False)
603603
```
604604
```{r}
605-
#| echo: !expr F
605+
#| echo: false
606606
htmltools::includeHTML(py$file)
607607
```
608608

@@ -636,7 +636,7 @@ file = 'plotly-python/scatter-volcano.html'
636636
pl.io.write_html(fig, file = file, auto_open = False)
637637
```
638638
```{r}
639-
#| echo: !expr F
639+
#| echo: false
640640
htmltools::includeHTML(py$file)
641641
```
642642
:::
@@ -673,7 +673,7 @@ file = 'plotly-python/scatter-hover-volcano.html'
673673
pl.io.write_html(fig, file = file, auto_open = False)
674674
```
675675
```{r}
676-
#| echo: !expr F
676+
#| echo: false
677677
htmltools::includeHTML(py$file)
678678
```
679679

@@ -729,7 +729,7 @@ file = 'plotly-python/scatter-hover-update-volcano.html'
729729
pl.io.write_html(fig, file = file, auto_open = False)
730730
```
731731
```{r}
732-
#| echo: !expr F
732+
#| echo: false
733733
htmltools::includeHTML(py$file)
734734
```
735735
:::
@@ -838,7 +838,7 @@ To explore the leaflet package, we'll start out playing with a [dataset of Bigfo
838838

839839
```{r}
840840
#| label: leaflet-setup
841-
#| echo: !expr F
841+
#| echo: false
842842
if (!"leaflet" %in% installed.packages()) install.packages("leaflet")
843843
844844
library(leaflet)
@@ -848,7 +848,7 @@ bigfoot_data <- read_csv("https://query.data.world/s/egnaxxvegdkzzrhfhdh4izb6etm
848848
```
849849
```{r}
850850
#| label: leaflet-setup
851-
#| eval: !expr F
851+
#| eval: false
852852
```
853853

854854
We can start out by plotting a map with the location of each sighting. I've colored the points in a seasonal color scheme, and added the description of each incident as a mouseover label.
@@ -899,7 +899,7 @@ We can also plot regions, instead of just points. I downloaded a dataset release
899899

900900
I've set this chunk to not evaluate because it causes the book to be painfully large.
901901
```{r}
902-
#| eval: !expr F
902+
#| eval: false
903903
library(sf)
904904
bees <- st_read("../data/Crotch_s_Bumble_Bee_Range_-_CDFW_[ds3095].geojson")
905905
bees <- sf::st_transform(bees, 4326)

0 commit comments

Comments
 (0)