-
Notifications
You must be signed in to change notification settings - Fork 1
/
22-importing.Rmd
40 lines (25 loc) · 1.13 KB
/
22-importing.Rmd
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
38
39
# Importing {#importing}
## Setup
```{r}
library(tidyverse)
library(readxl)
library(WDI)
library(owidR)
library(wid)
```
## EDA by R Studio: Step 3 - Importing Data
Assign a name you can recall easily when you import data. You may need to reload the data with options.
3.1. Use a package:
* WDI, wir, eurostat, etc/
* `wdi_shortname <- WDI(indicator = "indicator's name", ... )
* Store the data and use it: `write_csv(wdi_shortname, "./data/wdi_shortname.csv")`
* `wdi_shortname <- read_csv("./data/wdi_shortname.csv")`
3.2. Use `readr` to read from `data`, your data folder
* `df1_shortname <- read_csv("./data/file_name.csv")`
3.3. Use `readr` to read using the url of the data
* `df2_shortname <- read_csv("url_of_the_data")`
* Store the data and use it: `write_csv(df2_shortname, "./data/df2_shortname.csv")`
* `df2_shortname <- read_csv("./data/df2_shortname.csv")`
3.5. Use `readxl` to read Excel data. Add `library(readxl)` in the setup and run.
* `df4 <- read_excel("./data/file_name.xlsx", sheet = 1)`
References: Cheat Sheet - `readr`, [readr](https://readr.tidyverse.org), [readxl](https://readxl.tidyverse.org)