library(lubridate)
library(tidyverse)
library(fpp3)
# ggplot theme:
theme_set(
theme_bw() +
theme(panel.grid.minor = element_blank(),
panel.grid.major = element_blank())
)
# Daily production:
dat <- tibble(
date = seq(as.Date("2015-01-01"), as.Date("2019-12-31"), by = "1 day"),
price = pi
) %>%
#Removing the weekends:
filter(wday(date, week_start = 1) %in% 1:5) %>%
#Note: We do not remove public holidays, and the worker never takes a day off
mutate(YearMonth = yearmonth(date))
# -- TOTAL PRODUCTION FIGURE --
dat %>%
group_by(YearMonth) %>%
summarize(`Total production` = sum(price)) %>%
as_tsibble(index = "YearMonth") %>%
ggplot(aes(x = YearMonth,
y = `Total production`)) +
geom_point(color = "skyblue") +
geom_line(color = "skyblue") +
scale_y_continuous(breaks = seq(60, 100, 5),
labels = paste0("$",seq(60, 100, 5),"k"),
limits = c(60,75))
# -- MEAN PRODUCTION FIGURE --
dat %>% group_by(YearMonth) %>%
summarize(`Mean production` = mean(price)) %>%
as_tsibble(index = "YearMonth") %>%
ggplot(aes(x = YearMonth,
y = `Mean production`)) +
geom_point(color = "skyblue") +
geom_line(color="skyblue")+
scale_y_continuous(breaks = seq(3, 4, .02),
labels = paste0("$",seq(3, 4, .02),"k"))