Notes: Setting up my R environment by loading the ‘tidyverse’ and ‘palmerpenguins’ packages:
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(palmerpenguins)
The penguins dataset contains size measurements for three penguin species (Adelie, Chinstrap, and Gentoo) that live on the Palmer Archipelago in Antarctica. The columns include variables such as body mass, flipper length, and bill length. For more information see Github link describing dataset and additional details to download files.
summary(penguins)
## species island bill_length_mm bill_depth_mm
## Adelie :152 Biscoe :168 Min. :32.10 Min. :13.10
## Chinstrap: 68 Dream :124 1st Qu.:39.23 1st Qu.:15.60
## Gentoo :124 Torgersen: 52 Median :44.45 Median :17.30
## Mean :43.92 Mean :17.15
## 3rd Qu.:48.50 3rd Qu.:18.70
## Max. :59.60 Max. :21.50
## NA's :2 NA's :2
## flipper_length_mm body_mass_g sex year
## Min. :172.0 Min. :2700 female:165 Min. :2007
## 1st Qu.:190.0 1st Qu.:3550 male :168 1st Qu.:2007
## Median :197.0 Median :4050 NA's : 11 Median :2008
## Mean :200.9 Mean :4202 Mean :2008
## 3rd Qu.:213.0 3rd Qu.:4750 3rd Qu.:2009
## Max. :231.0 Max. :6300 Max. :2009
## NA's :2 NA's :2
The goal is to plot the relationship between body mass and flipper length in the three penguin species.
Here we will go through a series of visualizations
Flipper and body mass in purple
Here, we plot flipper length against body mass
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
Here, we plot flipper length against body mass and look at breakdown by species
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
Here, we plot flipper length against body mass and look at the breakdown by species and sex
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
The plot shows a positive relationship between the two variables. In other words, the larger the penguin, the longer the flipper. Gentoo Penguins are shown as the largest species.
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.