A minimal example

Author

First Last

Published

January 16, 2024

Data

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

library(tidyverse)
library(ggthemes)
library(palmerpenguins)
library(gt)

Species

Figure 1 is a scatterplot of species of penguins.

ggplot(data = penguins,
       mapping = aes(x = bill_length_mm, 
                     y = bill_depth_mm,
                     color = species,
                     shape = species)) +
  geom_point() +
  scale_color_colorblind() +
  labs(x = "Bill length (mm)", y = "Bill depth (mm)") +
  theme_minimal()

Figure 1: Bill length and depth of penguins

Penguins

Table 1 shows a summary of for the bill depth of penguins by island and species.

penguins |> 
  filter(!is.na(bill_depth_mm)) |> 
  group_by(island, species) |>
  summarise(n = n(),
            mean_bill_depth = mean(bill_depth_mm),
            sd_bill_depth = sd(bill_depth_mm)) |>
  ungroup() |> 
  gt() |> 
  fmt_number(columns = c(mean_bill_depth, sd_bill_depth),
             decimals = 1)
Table 1:

Bill depth of penquins by island and species.

island species n mean_bill_depth sd_bill_depth
Biscoe Adelie 44 18.4 1.2
Biscoe Gentoo 123 15.0 1.0
Dream Adelie 56 18.3 1.1
Dream Chinstrap 68 18.4 1.1
Torgersen Adelie 51 18.4 1.3