One of the ways to make boxplots is with package ggplot2
. If you wanted a single box, it would be easy - ggplot(df, aes(Fleas)) + geom_boxplot()
. If you wanted that stratified by age, it would be ggplot(df, aes(Fleas, Age)) + geom_boxplot()
.
However you want it to be stratified by both age and insect type. In this case, you can achieve this by reshaping the dataset longer first - see code below.
I created a sample dataset (please next time create a reproducible example like so, so it's easier for people to help you: we can't copy and paste a screenshot of data into R).
# Load libraries
library(ggplot2)
library(tidyr)
# Create a sample dataframe
df <- tibble(
`Squirrel no.` = 1:100,
Age = sample(c("Adult", "Juvenile"), replace = T, size = 100),
Fleas = round(rnorm(100, mean = 7, sd = 5)),
Lice = round(rnorm(100, mean = 12, sd = 6)),
Mites = round(rnorm(100, mean = 21, sd = 7))))
# Reshape the dataframe
df %>% pivot_longer(c(Fleas, Lice, Mites)) %>%
# Set the key variables
ggplot(aes(x = value, y = name, fill = Age)) +
# Specify the type of plot
geom_boxplot()
Output:

You can customise this rudimental Box plot - plenty of online material on ggplot2
.