Hello, Penguins!

Author

ALocke

Introduction

Data

For this analysis we’ll use the penguins dataset from the palmerpenguins package.

library(tidyverse)
library(ggthemes)
library(palmerpenguins)
library(gt)
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…

Species

Figure 1 is a scatterplot of species of penguins.

ggplot(
  penguins,
  aes(
    x=bill_length_mm, y=bill_depth_mm,
    color=species, shape=species
  )
) +
  geom_point() +
  theme_minimal() +
  scale_color_colorblind() +
  labs(x="Bill length (mm)", y="Bill depth (mm)")
A scatterplot of penguins' bill depth and length, colored by species of penguins. There is a relatively strong, linear association.
Figure 1: A scatterplot of penguins’ bill depth and length, colored by species of penguins.

Penguins

Table 1 ((Gorman, Williams, and Fraser 2014)) shows the first 10 penguins from the dataset.

penguins |>
  slice_head(n=10) |>
  select(species, island, bill_length_mm, bill_depth_mm) |>
  gt()
Table 1: First 10 penguins
species island bill_length_mm bill_depth_mm
Adelie Torgersen 39.1 18.7
Adelie Torgersen 39.5 17.4
Adelie Torgersen 40.3 18.0
Adelie Torgersen NA NA
Adelie Torgersen 36.7 19.3
Adelie Torgersen 39.3 20.6
Adelie Torgersen 38.9 17.8
Adelie Torgersen 39.2 19.6
Adelie Torgersen 34.1 18.1
Adelie Torgersen 42.0 20.2

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

1 + 1
[1] 2

You can add options to executable code like this

[1] 4

The echo: false option disables the printing of code (only output is displayed).

Let’s try to refer to the first figure again: Figure 1.

References

Gorman, Kristen B., Tony D. Williams, and William R. Fraser. 2014. “Ecological Sexual Dimorphism and Environmental Variability Within a Community of Antarctic Penguins (Genus Pygoscelis).” Edited by André Chiaradia. PLoS ONE 9 (3): e90081. https://doi.org/10.1371/journal.pone.0090081.