Trims the time range of an mts object by removing time steps from the start and end that contain only missing values.
mts_trim(mts = NULL)
mts object.
A subset of the incoming mts time series object.
(A list with meta
and data
dataframes.)
library(MazamaTimeSeries)
# Untrimmed range
range(example_mts$data$datetime)
#> [1] "2019-07-01 07:00:00 UTC" "2019-07-08 06:00:00 UTC"
# Replace the first 50 data values for all non-"datetime" columns
example_mts$data[1:50, -1] <- NA
# Trimmed range
mts_trimmed <- mts_trim(example_mts)
range(mts_trimmed$data$datetime)
#> [1] "2019-07-03 09:00:00 UTC" "2019-07-08 06:00:00 UTC"