View source: R/util_functions.R
ts_split | R Documentation |
Split a time series object into training and testing partitions
ts_split(ts.obj, sample.out = NULL)
ts.obj |
A univariate time series object of a class "ts" or "tsibble" |
sample.out |
An integer, set the number of periods of the testing or sample out partition, defualt set for 30 percent of the lenght of the series |
## Split the USgas dataset into training and testing partitions
## Set the last 12 months as a testing partition
## and the rest as a training partition
data(USgas, package = "TSstudio")
split_USgas <- ts_split(ts.obj = USgas, sample.out = 12)
training <- split_USgas$train
testing <- split_USgas$test
length(USgas)
length(training)
length(testing)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.