Packages
install.packages("name")
Downloads files
to your computer
Do this once per computer
install.packages("name")
Downloads files
to your computer
Do this once per computer
library("name")
Loads the package
Do this once per R session
"The tidyverse is an opinionated collection of R packages designed for data science. All packages share an underlying design philosophy, grammar, and data structures."
… the tidyverse makes data science faster, easier and more fun…
From "Master the Tidyverse" by RStudio
library(tidyverse)
The tidyverse package is a shortcut for
installing and loading all the key tidyverse packages
install.packages("tidyverse")
install.packages("ggplot2")install.packages("dplyr")install.packages("tidyr")install.packages("readr")install.packages("purrr")install.packages("tibble")install.packages("stringr")install.packages("forcats")install.packages("lubridate")install.packages("hms")install.packages("DBI")install.packages("haven")install.packages("httr")install.packages("jsonlite")install.packages("readxl")install.packages("rvest")install.packages("xml2")install.packages("modelr")install.packages("broom")
install.packages("tidyverse")
install.packages("ggplot2")install.packages("dplyr")install.packages("tidyr")install.packages("readr")install.packages("purrr")install.packages("tibble")install.packages("stringr")install.packages("forcats")install.packages("lubridate")install.packages("hms")install.packages("DBI")install.packages("haven")install.packages("httr")install.packages("jsonlite")install.packages("readxl")install.packages("rvest")install.packages("xml2")install.packages("modelr")install.packages("broom")
library("tidyverse")
library("ggplot2")library("dplyr")library("tidyr")library("readr")library("purrr")library("tibble")library("stringr")library("forcats")
Rectangular data
Data frames are the most common kind of data objects; used for rectangular data (like spreadsheets)
Data frames are the most common kind of data objects; used for rectangular data (like spreadsheets)
Data frames: R's native data object
Data frames are the most common kind of data objects; used for rectangular data (like spreadsheets)
Data frames: R's native data object
Tibbles (tbl
): a fancier enhanced kind of data frame
Data frames are the most common kind of data objects; used for rectangular data (like spreadsheets)
Data frames: R's native data object
Tibbles (tbl
): a fancier enhanced kind of data frame
(You really won't notice a difference today)
Vectors and lists
Vectors are a list of values of the same time
(all text, or all numbers, etc.)
Make them with c()
:
c(1, 4, 2, 5, 7)
Vectors are a list of values of the same time
(all text, or all numbers, etc.)
Make them with c()
:
c(1, 4, 2, 5, 7)
You'll usually want to assign them to something:
neat_numbers <- c(1, 4, 2, 5, 7)
Integer | Whole numbers | c(1, 2, 3, 4) |
Double | Numbers | c(1, 2.4, 3.14, 4) |
Character | Text | c("1", "blue", "fun", "monster") |
Logical | True or false | c(TRUE, FALSE, TRUE, FALSE) |
Factor | Category | c("Strongly disagree", "Agree", "Neutral") |
Importing data
![]() |
Work with plain text data | my_data <- read_csv("file.csv") |
![]() |
Work with Excel files | my_data <- read_excel("file.xlsx") |
![]() |
Work with Stata, SPSS, and SAS data | my_data <- read_stata("file.dta") |
Package | Type of data |
---|---|
jsonlite | JSON data |
xml2 | XML data |
httr | Web APIs |
rvest | Web pages (web scraping) |
DBI | Databases (SQL) |
Data visualization
Packages
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
o | Tile View: Overview of Slides |
Esc | Back to slideshow |
Packages
install.packages("name")
Downloads files
to your computer
Do this once per computer
install.packages("name")
Downloads files
to your computer
Do this once per computer
library("name")
Loads the package
Do this once per R session
"The tidyverse is an opinionated collection of R packages designed for data science. All packages share an underlying design philosophy, grammar, and data structures."
… the tidyverse makes data science faster, easier and more fun…
From "Master the Tidyverse" by RStudio
library(tidyverse)
The tidyverse package is a shortcut for
installing and loading all the key tidyverse packages
install.packages("tidyverse")
install.packages("ggplot2")install.packages("dplyr")install.packages("tidyr")install.packages("readr")install.packages("purrr")install.packages("tibble")install.packages("stringr")install.packages("forcats")install.packages("lubridate")install.packages("hms")install.packages("DBI")install.packages("haven")install.packages("httr")install.packages("jsonlite")install.packages("readxl")install.packages("rvest")install.packages("xml2")install.packages("modelr")install.packages("broom")
install.packages("tidyverse")
install.packages("ggplot2")install.packages("dplyr")install.packages("tidyr")install.packages("readr")install.packages("purrr")install.packages("tibble")install.packages("stringr")install.packages("forcats")install.packages("lubridate")install.packages("hms")install.packages("DBI")install.packages("haven")install.packages("httr")install.packages("jsonlite")install.packages("readxl")install.packages("rvest")install.packages("xml2")install.packages("modelr")install.packages("broom")
library("tidyverse")
library("ggplot2")library("dplyr")library("tidyr")library("readr")library("purrr")library("tibble")library("stringr")library("forcats")
Rectangular data
Data frames are the most common kind of data objects; used for rectangular data (like spreadsheets)
Data frames are the most common kind of data objects; used for rectangular data (like spreadsheets)
Data frames: R's native data object
Data frames are the most common kind of data objects; used for rectangular data (like spreadsheets)
Data frames: R's native data object
Tibbles (tbl
): a fancier enhanced kind of data frame
Data frames are the most common kind of data objects; used for rectangular data (like spreadsheets)
Data frames: R's native data object
Tibbles (tbl
): a fancier enhanced kind of data frame
(You really won't notice a difference today)
Vectors and lists
Vectors are a list of values of the same time
(all text, or all numbers, etc.)
Make them with c()
:
c(1, 4, 2, 5, 7)
Vectors are a list of values of the same time
(all text, or all numbers, etc.)
Make them with c()
:
c(1, 4, 2, 5, 7)
You'll usually want to assign them to something:
neat_numbers <- c(1, 4, 2, 5, 7)
Integer | Whole numbers | c(1, 2, 3, 4) |
Double | Numbers | c(1, 2.4, 3.14, 4) |
Character | Text | c("1", "blue", "fun", "monster") |
Logical | True or false | c(TRUE, FALSE, TRUE, FALSE) |
Factor | Category | c("Strongly disagree", "Agree", "Neutral") |
Importing data
![]() |
Work with plain text data | my_data <- read_csv("file.csv") |
![]() |
Work with Excel files | my_data <- read_excel("file.xlsx") |
![]() |
Work with Stata, SPSS, and SAS data | my_data <- read_stata("file.dta") |
Package | Type of data |
---|---|
jsonlite | JSON data |
xml2 | XML data |
httr | Web APIs |
rvest | Web pages (web scraping) |
DBI | Databases (SQL) |
Data visualization