0

Im trying to plot both the original data and my training data on the same graph with this code:

timeseries <- ts(df$new_cases_per_million, start=c(2021,2), end=c(2022,3), frequency=52)
ts_train <- window(timeseries,start=c(2021,2),end=c(2022,3))
ts_test  <- window(timeseries,start=c(2022,3))

autoplot(ts_train3,xlab="Year",series="ts_train3") + 
  autolayer(ts_test3,series = "Test set3") +
  ggtitle("timeseries plot")

However when I execute this code, the graph only plots the original data, and not my trained data: enter image description here

I also get this error with my plot:

geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?

I want it to look something like this: plot with original data and training data

Adam Quek
  • 6,973
  • 1
  • 17
  • 23
Tuey
  • 1
  • 2

0 Answers0