Given a time series, this function splits it into two, depending on the length of numTrain. The first numTrain observations go to the training set, the remainder into the testing set, while retaining the time series attributes of both objects and correctly adjusting the start times and frequencies of both sets.
splitTrainTest(dat, numTrain = length(dat) - 10)
Time series
The number of observations to keep in the training set