-
Notifications
You must be signed in to change notification settings - Fork 13
/
04-Import.Rmd
88 lines (59 loc) · 1.86 KB
/
04-Import.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
title: "Import Data"
output: html_notebook
editor_options:
chunk_output_type: inline
---
<!-- This file by Jake Thompson is licensed under a Creative Commons Attribution 4.0 International License, adapted from the orignal work at https://github.com/rstudio/master-the-tidyverse by RStudio. -->
```{r setup, include = FALSE}
library(tidyverse)
library(viridis)
setwd("/Users/jakethompson/Documents/GIT/courses/tidyds-2019")
```
## here()
```{r}
library(here)
here()
here("slides")
here("data", "nimbus.csv")
dr_here()
```
## Your Turn 1
Find nimbus.csv on your server or computer. Then read it into an object. Then view the results.
```{r}
nimbus <- ___
nimbus
```
## tibbles
```{r}
starwars
as.data.frame(starwars)
```
## Your Turn 2
* Read in the `nimbus` data set
* Set values of `.` to `NA`
```{r}
nimbus <- read_csv(here("data", "nimbus.csv"))
```
## Your Turn 3
* Modify the code to specify `ozone` as integer values
```{r}
nimbus <- read_csv(here("data", "nimbus.csv"), na = ".")
```
***
# Take Aways
The readr package provides efficient functions for reading and saving common flat file data formats. The tibble package provides improvements to the default data frame behavior.
Consider these packages for other types of data:
Package | Reads
------------------------- | -----------------------------------
readr | most flat files (.csv, .tsv, etc.)
readxl | excel files (.xls, .xlsx)
haven | SPSS, Stata, and SAS files
googlesheets, googledrive | Google Sheets and Google Drive
feather | Data transfers between R and Python
rvest | web pages (web scraping)
sparklyr | data loaded into spark
jsonlite | json
xml2 | xml
httr | web API's
DBI | databases