prepare.ts {autoTS} | R Documentation |
Format 2 vectors in a proper object usable by all algorithms
prepare.ts(dates, values, freq, complete = 0)
dates |
A vector of dates that can be parsed by lubridate |
values |
A vector of same size as |
freq |
A chacracter string that indicates the frequency of the time series ("week", "month", "quarter", "day"). |
complete |
A numerical value (or NA) to fill the missing data points |
Creates a list with the time series in a dataframe and a ts object, and the frequency stored in decimal and litteral values. The result is meant to be put in the prophet or forecast functions
A list containing : a dataframe, a ts vector for the time series, and 2 scalars for its frequency
library(lubridate)
library(dplyr)
library(ggplot2)
dates <- seq(lubridate::as_date("2000-01-01"),lubridate::as_date("2010-12-31"),"quarter")
values <- rnorm(length(dates))
my.ts <- prepare.ts(dates,values,"month",complete = 0)
plot(my.ts$obj.ts)
ggplot(my.ts$obj.df,aes(dates,val)) + geom_line()