Skip to content

Commit 326c87c

Browse files
author
Susan Vanderplas
committed
Updates
Merge branch 'main' of github.com:srvanderplas/stat-computing-r-python # Conflicts: # part-wrangling/02c-good-graphics.qmd
2 parents d3e11db + 793dfda commit 326c87c

File tree

12 files changed

+1727
-289
lines changed

12 files changed

+1727
-289
lines changed

_quarto.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ book:
3131
reader-mode: true
3232
type: book
3333
medium: ebook
34+
isbn: 978-1-60962-358-6
35+
doi: https://doi.org/10.32873/unl.dc.024
3436
sidebar:
3537
style: floating
3638
page-footer:

data/rev-war-battles2.csv

Lines changed: 275 additions & 281 deletions
Large diffs are not rendered by default.

data/rev-war-battles3.RDS

7.21 KB
Binary file not shown.

images/Brain_human_normal_inferior_view.svg

Lines changed: 733 additions & 0 deletions
Loading
14.1 MB
Loading

images/wrangling/world-eyes-brain.png.2025_09_05_17_28_01.0.svg

Lines changed: 695 additions & 0 deletions
Loading
22.6 MB
Binary file not shown.

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,8 +1337,14 @@ When writing custom functions for web scrapign, it's usually helpful to give you
13371337
saveRDS(rev_war_battles2, "../data/rev-war-battles2.RDS")
13381338
```
13391339
```{r}
1340-
#| echo: !expr '-1'
1340+
#| include: false
1341+
#| eval: true
1342+
1343+
13411344
rev_war_battles2 <- readRDS("../data/rev-war-battles2.RDS")
1345+
```
1346+
1347+
```{r}
13421348
head(rev_war_battles2)
13431349
```
13441350

@@ -1359,7 +1365,7 @@ process_battle_row <- function(node){# <1>
13591365
13601366
rev_war_battles3 <- map(rev_war_rows, process_battle_row) |> bind_rows() # <4>
13611367
```
1362-
1. Here, the function is called on a single row of the table, so it's much harder to "lose" a value.
1368+
1. The function is called on a single row of the table, so it's much harder to "lose" a value.
13631369
2. First, get all first `td` elements with `a` children, and get the `href` attribute from those children. This will be `NULL` or `c()` (a list of length 0) if there is no `a` child of the first `td` element in the node.
13641370
3. The biggest modification here is to use `if_else()` to handle the missing values and replace them with NA instead.
13651371
4. Call `process_battle_row` on each row and bind the rows together.
@@ -1370,8 +1376,11 @@ rev_war_battles3 <- map(rev_war_rows, process_battle_row) |> bind_rows() # <4>
13701376
saveRDS(rev_war_battles3, "../data/rev-war-battles3.RDS")
13711377
```
13721378
```{r}
1373-
#| echo: !expr '-1'
1379+
#| eval: true
1380+
#| include: false
13741381
rev_war_battles3 <- readRDS("../data/rev-war-battles3.RDS")
1382+
```
1383+
```{r}
13751384
head(rev_war_battles3)
13761385
```
13771386

@@ -1382,8 +1391,9 @@ head(rev_war_battles3)
13821391
from bs4 import BeautifulSoup, SoupStrainer
13831392
import urllib.request
13841393
1394+
header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0'}
13851395
url = "https://en.wikipedia.org/wiki/List_of_American_Revolutionary_War_battles"
1386-
req = urllib.request.Request(url)
1396+
req = urllib.request.Request(url, headers=header)
13871397
13881398
page_bytearray = urllib.request.urlopen(req)
13891399
page = page_bytearray.read()

part-gen-prog/01-basic-var-types.qmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ In most programming languages (including R and python), there are some very basi
2727

2828
- **integer** - whole numbers (positive or negative)
2929

30-
- **double** or **float** or **numeric**- decimal numbers.
30+
- **double** or **float** - decimal numbers.
3131

3232
- **float** is short for floating-point value.
3333
- **double** is a floating-point value with more precision ("double precision").[^01-prog-intro-1]
34-
- R uses the name **numeric** to indicate a decimal value, regardless of precision.
3534

3635
- **character** or **string** - holds text, usually enclosed in quotes.
3736

part-tools/02-setting-up-computer.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,4 @@ If you prefer dark mode (or other color schemes), you can customize RStudio with
367367
There are also [keyboard shortcuts](https://support.posit.co/hc/en-us/articles/200711853-Keyboard-Shortcuts-in-the-RStudio-IDE) and you can set [custom shortcuts](https://docs.posit.co/ide/user/ide/guide/productivity/custom-shortcuts.html) as well.
368368

369369
Some people like fonts that use ligatures (multi-block characters). Ligatures can cause e.g. the assignment operator `<-` to look like $\leftarrow$ in your text editor. If you like this idea, then [you can enable font ligatures by installing Fira Code or another ligature-friendly font and allowing RStudio to use ligatures](https://stackoverflow.com/questions/34548194/rstudio-how-to-enable-font-ligatures-in-rstudio).
370-
:::
370+
:::

0 commit comments

Comments
 (0)