immediate solution
library(tsibble)
library(ggplot2)
DF <- data.frame(dt = as.Date(yearweek("2000W01") + 0:20), val = 0:20)
ggplot(DF, aes(x=dt, y=val)) +
geom_point() +
geom_vline(xintercept = as.Date(yearweek("2000 W10"))) +
scale_x_date(date_breaks = "4 weeks",date_labels = "%Y W%W")
I suppose it would be preferable to not need to map the yearweek to Date and further modify, but it seems the tsibble folks would need to implement more on their side to make a direct yearweek approach.
library(tsibble)
DF <- data.frame(dt = yearweek("2000W01") + 0:20, val = 0:20)
ggplot(DF, aes(x=dt, y=val)) +
geom_point() +
geom_vline(xintercept = yearweek("2000 W10"))
Error in UseMethod("rescale") :
no applicable method for 'rescale' applied to an object of class "c('yearweek', 'vctrs_vctr')"
The tsibble issues board is here :
Issues · tidyverts/tsibble (github.com)