initial_data <- data.frame(
fulldate = seq.Date(
from = as.Date("2010-01-01"),
by = "month",
length.out = 84
),
code = 620 + cumsum(sample(c(-1, 1), 84, TRUE))
)
library(tidyverse)
library(lubridate)
prepared_data <- initial_data %>% mutate(
yearpart = year(fulldate),
months_common_year = ymd(2010 * 10000 + 100 * month(fulldate) + day(fulldate))
)
ggplot(
data = prepared_data,
mapping = aes(
x = months_common_year,
y = code
)
) +
facet_wrap(~yearpart, ncol = 1) +
geom_line() +
scale_x_date(date_labels = "%b", date_breaks = "1 month")