It is interesting if there is a function for constructing the ts object directly ggplot2. I used to use the following strategy, but now it throws an error.
set.seed(12345) dat <- ts(data=runif(n=10, min=50, max=100), frequency = 4, start = c(1959, 2)) df <- data.frame(date=as.Date(time(dat)), Y=as.matrix(dat)) library(ggplot2) ggplot(data=df, mapping=aes(x=date, y=Y))+geom_point()
error
Error in as.Date.default(time(dat)) : do not know how to convert 'time(dat)' to class "Date"
How can I directly build a ts object with ggplot2 .
source share