Is it possible to add a vertical line to a ggplot graph with data of class Week on the x-axis? For example
library(tsibble)
#>
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, union
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.1.3
DF <- data.frame(dt = yearweek("2000W01") + 0:20, val = 0:20)
ggplot(DF, aes(x=dt, y=val)) +
geom_point() +
geom_vline(xintercept = as.numeric(yearweek("2000 W10")))
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')"