prepare.ts {autoTS}R Documentation

Format 2 vectors in a proper object usable by all algorithms

Description

Format 2 vectors in a proper object usable by all algorithms

Usage

prepare.ts(dates, values, freq, complete = 0)

Arguments

dates

A vector of dates that can be parsed by lubridate

values

A vector of same size as dates

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

Details

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

Value

A list containing : a dataframe, a ts vector for the time series, and 2 scalars for its frequency

Examples

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()

[Package autoTS version 0.9.11 Index]