hadley / r4ds

R for data science: a book
http://r4ds.hadley.nz
Other
4.59k stars 4.22k forks source link

Where to find gapminder xlsx files? #1605

Open mdavis-xyz opened 12 months ago

mdavis-xyz commented 12 months ago

I'm reading Iteration: 26.3.1 Listing files in a directory:

To make our motivating example concrete, this book contains a folder with 12 excel spreadsheets containing data from the gapminder package.

paths <- list.files("data/gapminder", pattern = "[.]xlsx$", full.names = TRUE)
paths
#>  [1] "data/gapminder/1952.xlsx" "data/gapminder/1957.xlsx"
#>  [3] "data/gapminder/1962.xlsx" "data/gapminder/1967.xlsx"
#>  [5] "data/gapminder/1972.xlsx" "data/gapminder/1977.xlsx"
#>  [7] "data/gapminder/1982.xlsx" "data/gapminder/1987.xlsx"
#>  [9] "data/gapminder/1992.xlsx" "data/gapminder/1997.xlsx"
#> [11] "data/gapminder/2002.xlsx" "data/gapminder/2007.xlsx"

I assume I'm supposed to still be following along by running each code snippet on my computer. But am I supposed to have access to these files already? I don't see any hyperlinks to the dataset from the page. Are users supposed to know that they should navigate to the github folder? Or is this available on https://r4ds.hadley.nz somewhere? (wget -r couldn't find them.) Or should I replace data/gapminder with some function from the gapminder package that returns a path to a folder of these files?

As a second, lesser point, when I run this code I get an empty list:

> paths <- list.files("data/gapminder", pattern = "[.]xlsx$", full.names = TRUE)
> paths
character(0)

I find this behaviour surprising. I was expecting an error, because the folder doesn't exist. (Like ls in bash, or python's os.listdir.) Perhaps it's worth mentioning this behaviour?