Notes: setting up my R
environment by loading the
tidyverse
and palmer penguins
packages
library(tidyverse)
library(palmerpenguins)
data(penguins)
palmer penguins
dataglimpse(penguins)
## Rows: 344
## Columns: 8
## $ species <fct> Adelie, Adelie, Adelie, Adelie, Adelie, Adelie, Adel…
## $ island <fct> Torgersen, Torgersen, Torgersen, Torgersen, Torgerse…
## $ bill_length_mm <dbl> 39.1, 39.5, 40.3, NA, 36.7, 39.3, 38.9, 39.2, 34.1, …
## $ bill_depth_mm <dbl> 18.7, 17.4, 18.0, NA, 19.3, 20.6, 17.8, 19.6, 18.1, …
## $ flipper_length_mm <int> 181, 186, 195, NA, 193, 190, 181, 195, 193, 190, 186…
## $ body_mass_g <int> 3750, 3800, 3250, NA, 3450, 3650, 3625, 4675, 3475, …
## $ sex <fct> male, female, female, NA, female, male, female, male…
## $ year <int> 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007…
Here we will go through a series of visualizations
Here, we plot flipper length against body mass
ggplot(data=penguins,
aes(x = flipper_length_mm, y = body_mass_g))+
geom_point(color = "purple")
Here, we plot flipper length against body mass and look at the breakdown by species
ggplot(data=penguins,
aes(x = flipper_length_mm, y = body_mass_g))+
geom_point(aes(shape=species))
Here, we plot flipper length against body mass and look at the breakdown by species and sex
ggplot(data=penguins,
aes(x = flipper_length_mm, y = body_mass_g))+
geom_point(aes(color=species,
shape=species)) +
facet_wrap(~sex)
Here, we plot flipper length against body mass and look at the breakdown by species and sex (ignoring NA values)
penguins %>%
drop_na(sex) %>%
ggplot(aes(x = flipper_length_mm, y = body_mass_g)) +
geom_point(aes(color = species,
shape = species)) +
facet_wrap(~sex)