Hi @tdheer, this would be my approach (please next time provide you data in a copy-paste-safe way!):
Hope this is what you're looking for.
library(tibble)
library(dplyr)
library(tidyr)
library(ggplot2)
# create dataframe
d <- tribble(
~year, ~Qtr1, ~Qtr, ~Qtr3, ~Qtr4,
"1960", "5387", "6211", "6659", "5983",
"1961", "5709", "6458", "6875", "6162",
"1962", "6098", "7075", "7595", "6882",
"1963", "6707", "7874", "8555", "7503",
"1964", "7469", "8829", "9513", "8415",
"1965", "8270", "9503", "10306", "9077"
) %>%
mutate_all(as.numeric) # make all values numeric
# transform dataframe to long format
d_long <- d %>%
pivot_longer(
cols = -year,
names_to = "quarter",
values_to = "n"
)
# boxplot for each quarter, aggregating across years
ggplot(d_long, aes(quarter, n)) +
geom_boxplot()
This code generates something like this: