day 19_smooth

Author
Published

April 19, 2025

Egg prices in the USA are high right now, mostly due to supply issues caused by bird flu outbreaks. I was interested in how prices compare to egg prices in NZ, which have been high since battery farms bans went into effect in 2022.

The data for these plots came from StatsNZ and the US Bureau of Labor Statistics and required a bit of wrangling to make the formats consistent. You can find the code that I wrote to read in and clean the egg data in this .R script

read data/fix dates

library(tidyverse)
library(here)

eggs <- read_csv(here("charts", "2025-04-19_smooth", "eggsNZUSA.csv")) 


eggs <- eggs %>%
    mutate(month_year = paste0(month, "_", year)) %>%
  mutate(date = lubridate::my(month_year))

glimpse(eggs)
Rows: 253
Columns: 6
$ year       <dbl> 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015,…
$ month      <chr> "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Se…
$ price      <dbl> 3.78, 3.79, 3.64, 3.71, 3.87, 3.83, 3.81, 3.77, 3.74, 3.76,…
$ currency   <chr> "NZD", "NZD", "NZD", "NZD", "NZD", "NZD", "NZD", "NZD", "NZ…
$ month_year <chr> "Jan_2015", "Feb_2015", "Mar_2015", "Apr_2015", "May_2015",…
$ date       <date> 2015-01-01, 2015-02-01, 2015-03-01, 2015-04-01, 2015-05-01…

plot

The Quarto panel tabset is a nice way of comparing different plot options here. I think the smooth option looks better with slightly transparent points.

eggs %>%
  ggplot(aes(x = date, y = price, colour = currency)) +
  geom_point() +
  geom_line() +
  scale_colour_brewer(palette = "Dark2", name = "Country", labels = c("NZ", "USA")) +
  theme_minimal() +
  labs(y = "Price per dozen ($)", x = "Year", 
       title = "Egg prices (per dozen) over time", 
       caption = "NZ Data from StatsNZ; \nUS Data from Bureau of Labor Statistics")

eggs %>%
  ggplot(aes(x = date, y = price, colour = currency)) +
  geom_point(alpha = 0.5) +
  geom_smooth(se = FALSE, na.rm = TRUE) +
  scale_colour_brewer(palette = "Dark2", name = "Country", labels = c("NZ", "USA")) +
  theme_minimal() +
  labs(y = "Price per dozen ($)", x = "Year", 
       title = "Egg prices (per dozen) over time", 
       caption = "NZ Data from StatsNZ; \nUS Data from Bureau of Labor Statistics")