-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsession-csv-url.qmd
37 lines (22 loc) · 1.13 KB
/
session-csv-url.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
title: "Introduction to R and Rstudio"
subtitle: "Session - import csv from the web"
---
## URLs imports
Sometimes it's easier to directly retrieve the csv files from the source on the internet.
This removes a step in the Reproducible Analytical Pipeline where a person is required to save the file to import.
## Importing csvs using {readr}
We will use the "Import Dataset" button which is the same way to get csv files from a computer:
<img src="img/session03/import-screenshot.PNG" alt="Screenshot of RStudio with Import Dataset drop down button highlighted" class="center" width="80%"/>
## File location - using a url
Instead of selecting a file, instead copy the url into the `File/URL` box next to `Browse`
```
https://www.ethnicity-facts-figures.service.gov.uk/culture-and-community/digital/internet-use/latest/downloads/by-ethnicity.csv
```
. . .
Browse changes to `Update` which will pressed will give a preview and the code is:
```{r}
library(readr)
by_ethnicity <- read_csv(url("https://www.ethnicity-facts-figures.service.gov.uk/culture-and-community/digital/internet-use/latest/downloads/by-ethnicity.csv"))
```
## End session