Updates so URL fits on a single line
This commit is contained in:
parent
9ef9685618
commit
45aee03c4b
|
@ -554,7 +554,9 @@ This is the same dataset as in @fig-students-excel, except it's stored in a Goog
|
||||||
knitr::include_graphics("screenshots/import-googlesheets-students.png")
|
knitr::include_graphics("screenshots/import-googlesheets-students.png")
|
||||||
```
|
```
|
||||||
|
|
||||||
The first argument to `read_sheet()` is the URL of the file to read, and it returns a tibble:
|
The first argument to `read_sheet()` is the URL of the file to read, and it returns a tibble:\
|
||||||
|
<https://docs.google.com/spreadsheets/d/1V1nPp1tzOuutXFLb3G9Eyxi3qxeEhnOXUzL5_BcCQ0w>.
|
||||||
|
These URLs are not pleasant to work with, so you'll often want to identify a sheet by its ID.
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
#| include: false
|
#| include: false
|
||||||
|
@ -563,8 +565,8 @@ gs4_deauth()
|
||||||
```
|
```
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
students_url <- "https://docs.google.com/spreadsheets/d/1V1nPp1tzOuutXFLb3G9Eyxi3qxeEhnOXUzL5_BcCQ0w"
|
students_sheet_id <- "1V1nPp1tzOuutXFLb3G9Eyxi3qxeEhnOXUzL5_BcCQ0w"
|
||||||
students <- read_sheet(students_url)
|
students <- read_sheet(students_sheet_id)
|
||||||
students
|
students
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -572,7 +574,7 @@ Just like we did with `read_excel()`, we can supply column names, NA strings, an
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
students <- read_sheet(
|
students <- read_sheet(
|
||||||
students_url,
|
students_sheet_id,
|
||||||
col_names = c("student_id", "full_name", "favourite_food", "meal_plan", "age"),
|
col_names = c("student_id", "full_name", "favourite_food", "meal_plan", "age"),
|
||||||
skip = 1,
|
skip = 1,
|
||||||
na = c("", "N/A"),
|
na = c("", "N/A"),
|
||||||
|
@ -589,14 +591,14 @@ It's also possible to read individual sheets from Google Sheets as well.
|
||||||
Let's read the "Torgersen Island" sheet from the [penguins Google Sheet](https://pos.it/r4ds-penguins):
|
Let's read the "Torgersen Island" sheet from the [penguins Google Sheet](https://pos.it/r4ds-penguins):
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
penguins_url <- "https://docs.google.com/spreadsheets/d/1aFu8lnD_g0yjF5O-K6SFgSEWiHPpgvFCF0NY9D6LXnY"
|
penguins_sheet_id <- "1aFu8lnD_g0yjF5O-K6SFgSEWiHPpgvFCF0NY9D6LXnY"
|
||||||
read_sheet(penguins_url, sheet = "Torgersen Island")
|
read_sheet(penguins_sheet_id, sheet = "Torgersen Island")
|
||||||
```
|
```
|
||||||
|
|
||||||
You can obtain a list of all sheets within a Google Sheet with `sheet_names()`:
|
You can obtain a list of all sheets within a Google Sheet with `sheet_names()`:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
sheet_names(penguins_url)
|
sheet_names(penguins_sheet_id)
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, just like with `read_excel()`, we can read in a portion of a Google Sheet by defining a `range` in `read_sheet()`.
|
Finally, just like with `read_excel()`, we can read in a portion of a Google Sheet by defining a `range` in `read_sheet()`.
|
||||||
|
|
Loading…
Reference in New Issue