This report explores the Palmer Penguins dataset, which contains data on 344 penguins from three species — Adelie, Chinstrap, and Gentoo — observed across three islands in the Palmer Archipelago, Antarctica. The data were collected by Dr. Kristen Gorman.
The goal of this analysis is to examine the physical characteristics of each species, explore ecological differences across islands, and visualize key relationships within the dataset. This analysis demonstrates how exploratory data analysis and visualization can reveal biological differences among species and highlight ecological patterns across habitats.
library(tidyverse)
library(palmerpenguins)
head(penguins)
## # A tibble: 6 × 8
## species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
## <fct> <fct> <dbl> <dbl> <int> <int>
## 1 Adelie Torgersen 39.1 18.7 181 3750
## 2 Adelie Torgersen 39.5 17.4 186 3800
## 3 Adelie Torgersen 40.3 18 195 3250
## 4 Adelie Torgersen NA NA NA NA
## 5 Adelie Torgersen 36.7 19.3 193 3450
## 6 Adelie Torgersen 39.3 20.6 190 3650
## # ℹ 2 more variables: sex <fct>, year <int>
nrow(penguins)
## [1] 344
ncol(penguins)
## [1] 8
glimpse(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…
colSums(is.na(penguins))
## species island bill_length_mm bill_depth_mm
## 0 0 2 2
## flipper_length_mm body_mass_g sex year
## 2 2 11 0
penguins %>%
group_by(species) %>%
summarise(
avg_bill_length = mean(bill_length_mm, na.rm = TRUE),
mid_bill_length = median(bill_length_mm, na.rm = TRUE),
min_bill_length = min(bill_length_mm, na.rm = TRUE),
max_bill_length = max(bill_length_mm, na.rm = TRUE),
sd_bill_length = sd(bill_length_mm, na.rm = TRUE),
avg_flipper_length = mean(flipper_length_mm, na.rm = TRUE),
mid_flipper_length = median(flipper_length_mm, na.rm = TRUE),
min_flipper_length = min(flipper_length_mm, na.rm = TRUE),
max_flipper_length = max(flipper_length_mm, na.rm = TRUE),
sd_flipper_length = sd(flipper_length_mm, na.rm = TRUE)
)
## # A tibble: 3 × 11
## species avg_bill_length mid_bill_length min_bill_length max_bill_length
## <fct> <dbl> <dbl> <dbl> <dbl>
## 1 Adelie 38.8 38.8 32.1 46
## 2 Chinstrap 48.8 49.6 40.9 58
## 3 Gentoo 47.5 47.3 40.9 59.6
## # ℹ 6 more variables: sd_bill_length <dbl>, avg_flipper_length <dbl>,
## # mid_flipper_length <dbl>, min_flipper_length <int>,
## # max_flipper_length <int>, sd_flipper_length <dbl>
penguins %>%
group_by(island) %>%
summarise(avg_body_mass = mean(body_mass_g, na.rm = TRUE)) %>%
arrange(-avg_body_mass)
## # A tibble: 3 × 2
## island avg_body_mass
## <fct> <dbl>
## 1 Biscoe 4716.
## 2 Dream 3713.
## 3 Torgersen 3706.
penguins <- penguins %>%
mutate(bill_ratio = bill_length_mm / bill_depth_mm)
head(penguins)
## # A tibble: 6 × 9
## species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
## <fct> <fct> <dbl> <dbl> <int> <int>
## 1 Adelie Torgersen 39.1 18.7 181 3750
## 2 Adelie Torgersen 39.5 17.4 186 3800
## 3 Adelie Torgersen 40.3 18 195 3250
## 4 Adelie Torgersen NA NA NA NA
## 5 Adelie Torgersen 36.7 19.3 193 3450
## 6 Adelie Torgersen 39.3 20.6 190 3650
## # ℹ 3 more variables: sex <fct>, year <int>, bill_ratio <dbl>
penguins %>%
select(species, bill_length_mm, bill_depth_mm, bill_ratio) %>%
head()
## # A tibble: 6 × 4
## species bill_length_mm bill_depth_mm bill_ratio
## <fct> <dbl> <dbl> <dbl>
## 1 Adelie 39.1 18.7 2.09
## 2 Adelie 39.5 17.4 2.27
## 3 Adelie 40.3 18 2.24
## 4 Adelie NA NA NA
## 5 Adelie 36.7 19.3 1.90
## 6 Adelie 39.3 20.6 1.91
penguins %>%
group_by(species) %>%
summarise(avg_bill_ratio = mean(bill_ratio, na.rm = TRUE)) %>%
arrange(-avg_bill_ratio)
## # A tibble: 3 × 2
## species avg_bill_ratio
## <fct> <dbl>
## 1 Gentoo 3.18
## 2 Chinstrap 2.65
## 3 Adelie 2.12
ggplot(data = penguins) +
geom_violin(mapping = aes(x = species, y = bill_ratio, fill = species),
alpha = 0.4,
trim = FALSE,
na.rm = TRUE) +
geom_boxplot(mapping = aes(x = species, y = bill_ratio),
width = 0.2,
fill = "white",
outlier.shape = NA,
na.rm = TRUE) +
stat_summary(mapping = aes(x = species, y = bill_ratio),
fun = "median",
geom = "point",
color = "black",
size = 2,
na.rm = TRUE) +
scale_fill_manual(values = c("darkorange", "purple", "cyan4")) +
labs(title = "Palmer Penguins: Bill Ratio by Species",
subtitle = "Bill Length / Bill Depth (higher = longer & narrower bill)",
x = "Species",
y = "Bill Ratio",
caption = "Data collected by Dr. Kristen Gorman") +
theme_minimal(base_size = 10) +
theme(legend.position = "none")
penguins %>%
filter(!is.na(sex)) %>%
count(species, sex)
## # A tibble: 6 × 3
## species sex n
## <fct> <fct> <int>
## 1 Adelie female 73
## 2 Adelie male 73
## 3 Chinstrap female 34
## 4 Chinstrap male 34
## 5 Gentoo female 58
## 6 Gentoo male 61
penguins %>%
filter(!is.na(sex)) %>%
group_by(species, sex) %>%
summarise(count = n(), .groups = "drop_last") %>%
mutate(percentage = count / sum(count) * 100)
## # A tibble: 6 × 4
## # Groups: species [3]
## species sex count percentage
## <fct> <fct> <int> <dbl>
## 1 Adelie female 73 50
## 2 Adelie male 73 50
## 3 Chinstrap female 34 50
## 4 Chinstrap male 34 50
## 5 Gentoo female 58 48.7
## 6 Gentoo male 61 51.3
penguins %>%
filter(!is.na(sex)) %>%
ggplot(mapping = aes(x = species, fill = sex)) +
geom_bar(position = "dodge") +
labs(title = "Palmer Penguins: Male vs Female Count by Species",
subtitle = "Excluding missing sex values",
x = "Species",
y = "Count",
fill = "Sex",
caption = "Data collected by Dr. Kristen Gorman") +
scale_fill_manual(values = c("female" = "hotpink", "male" = "steelblue")) +
theme_minimal(base_size = 10)
penguins %>%
group_by(island, species) %>%
summarise(count = n(), .groups = "drop")
## # A tibble: 5 × 3
## island species count
## <fct> <fct> <int>
## 1 Biscoe Adelie 44
## 2 Biscoe Gentoo 124
## 3 Dream Adelie 56
## 4 Dream Chinstrap 68
## 5 Torgersen Adelie 52
penguins %>%
group_by(island, species) %>%
summarise(count = n(), .groups = "drop") %>%
ggplot(mapping = aes(x = island, y = count, fill = species)) +
geom_bar(stat = "identity") +
labs(title = "Penguin Species Count by Island",
x = "Island",
y = "Count",
fill = "Species",
caption = "Data collected by Dr. Kristen Gorman") +
theme_minimal(base_size = 10)
ggplot(data = penguins) +
geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g, colour = species), na.rm = TRUE) +
labs(title = "Palmer Penguins: Body Mass vs. Flipper Length",
x = "Flipper Length (mm)",
y = "Body Mass (g)",
subtitle = "Sample of Three Penguin Species",
caption = "Data collected by Dr. Kristen Gorman") +
annotate("text", x = 220, y = 3700,
label =
"Gentoo penguins form a distinct cluster\nwith higher body mass and longer flippers",
colour = "black",
fontface = "bold",
size = 2) +
theme_minimal(base_size = 10)
cor.test(penguins$flipper_length_mm, penguins$body_mass_g,
use = "complete.obs")
##
## Pearson's product-moment correlation
##
## data: penguins$flipper_length_mm and penguins$body_mass_g
## t = 32.722, df = 340, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.843041 0.894599
## sample estimates:
## cor
## 0.8712018
Overall, the analysis reveals clear morphological differences among penguin species and strong relationships between physical traits and their habitat distribution.
Which species tends to be the largest overall? Gentoo penguins appear to be the largest species overall, exhibiting the highest average body mass and the longest flippers.
Is there a visible relationship between flipper length and body mass? Yes — penguins with longer flippers tend to have larger body mass. The three species also cluster into distinct groups.
Is there a statistically significant correlation between flipper length and body mass? Yes — a Pearson correlation test confirms a strong positive correlation (r = 0.87, p < 0.001), meaning penguins with longer flippers significantly tend to have greater body mass.
Which island has the most biodiversity? Both Biscoe and Dream Islands host two penguin species each, making them equally biodiverse. Torgersen Island is the least biodiverse, hosting only Adelie penguins. Notably, Adelie is the only species found across all three islands.
Which species has the highest bill ratio? Gentoo penguins have the highest mean bill ratio (3.18), meaning they have longer, narrower bills relative to their depth. Adelie penguins have the lowest ratio (2.12), with shorter, deeper bills.
What is the male vs female distribution across species? The sex distribution is remarkably balanced — Adelie and Chinstrap penguins are exactly 50/50 male to female, while Gentoo penguins are very close at 48.7% female and 51.3% male.
Missing values were minimal and handled using na.rm = TRUE, ensuring that summary statistics and visualizations were not biased by incomplete observations.
na.rm = TRUE and
filter(!is.na())mutate()cor.test()group_by() before
summarisingarrange(), select(),
count(), and summarise() to explore and
understand dataAnalysis completed by Daniel Eniola | Data source: palmerpenguins R package