I'm creating a series of using various time periods for a series of stock prices. For each stock, I create a graph for 1, 2, 3, 5, 10, and 15 years.
The code is something like
graphOutput <- data %>% ggplot() + geom_line(....) + geom_text(...)
How can I create the graph for 15 years, and then subset it for 10, 5, 3, 2, and 1 years and save elapsed and computational time? I've tried
graphOutput %>% filter(data$Date > "2022-06-01")
but I get the error message
*Error in UseMethod("filter") : *
- no applicable method for 'filter' applied to an object of class "c('gg', 'ggplot')"*