install.packages("ggplot2")
library(ggplot2)R, RStudio, and your first data frame
the nycflights23 tables flights
install.packages()library()glimpse()View()Everything in this chapter is a step you will repeat all semester.
Two different pieces of software. You install both, but you only ever open one of them.
The Engine & The Dashboard
Download a package from CRAN onto your computer. You do this once per package, in the console, never in an R Markdown file.
Install Once
A package is a bundle of functions and data someone else already wrote.
Example
download it (console only, once)
load it (every session)
Load an installed package so its functions are available. You do this every time you start a new R session.
Load Every Session
Save a value in an object so you can use it again. Type the object’s name on its own to see what it holds.
Example
the object’s name assign: store the right side in it
combine values into a vector the values
A rectangle of data: every column is a variable, every row is an observation.
Rows & Columns
Print every variable in a data frame down the page, with its type and its first few values.
Example
Rows: 435,352
Columns: 19
$ year <int> 2023, 2023, 2023, 2023, 2023, 2023, 2023, 202…
$ month <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
$ day <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
$ dep_time <int> 1, 18, 31, 33, 36, 503, 520, 524, 537, 547, 5…
$ sched_dep_time <int> 2038, 2300, 2344, 2140, 2048, 500, 510, 530, …
$ dep_delay <dbl> 203, 78, 47, 173, 228, 3, 10, -6, 17, 2, -10,…
# ... 13 more lines, not shown
the verb (function) the data frame
Each one tells you something different about a data frame.
Explore Your Data
The package holds five related tables. flights is the one this chapter works with.
Five Tables, One Package
Have these done and you will be ready to work along in class.
Checklist