
Lecture 7
Cornell University
INFO 2951 - Spring 2026
February 10, 2026
```{r}
#| label: plot-penguins-visible
#| echo: false
ggplot(penguins,
aes(x = flipper_len, y = bill_len)) +
geom_point(aes(color = species, shape = species)) +
scale_color_manual(values = c("darkorange","purple","cyan4")) +
labs(
x = "Flipper length (mm)", y = "Bill length (mm)",
color = "Penguin species", shape = "Penguin species"
) +
theme_minimal()
```
Generally speaking, larger flipper lengths correspond to larger bill lengths.
However Gentoo and Chinstrap tend to have longer bills than Adélie penguins,
and Gentoo also have longer flippers than either of the other species.
Generally speaking, larger flipper lengths correspond to larger bill lengths. However Gentoo and Chinstrap tend to have longer bills than Adélie penguins, and Gentoo also have longer flippers than either of the other species.
```{r}
#| label: plot-penguins-hidden
#| echo: false
ggplot(penguins,
aes(x = flipper_len, y = bill_len)) +
geom_point(aes(color = species, shape = species)) +
scale_color_manual(values = c("darkorange","purple","cyan4")) +
labs(
x = "Flipper length (mm)", y = "Bill length (mm)",
color = "Penguin species", shape = "Penguin species"
) +
theme_minimal()
# Generally speaking, larger flipper lengths correspond to larger bill lengths.
# However Gentoo and Chinstrap tend to have longer bills than Adélie penguins,
# and Gentoo also have longer flippers than either of the other species.
```
Vectors are the basic building block for storing data in R.
Image credit: R for Data Science (1st ed)
Type is how an object is stored in memory, e.g.,
double: a real number stored in double-precision floating point format.integer: an integer (positive or negative)Class is metadata about the object that can determine how common functions operate on that object, e.g.,
factordatedate-timeYou’ll commonly encounter:
logicalintegerdoublecharacterYou’ll less commonly encounter:
listNULLcomplexrawWe don’t typically think of them as lists, but data frames are lists where every element is a vector and they are all the same length.
Base R functions
as.logical()as.integer()as.double()as.character(){readr} functions
parse_logical()parse_integer()parse_double()parse_character()A factor is a vector that can contain only predefined values. It is used to store categorical data.
Just a couple of examples…
ae-05Instructions
ae-05 (repo name will be suffixed with your GitHub name).renv::restore() to install the required packages, open the Quarto document in the repo, and follow along and complete the exercises.year as a character type)