mts_trimDate | R Documentation |
Trims the date range of an mts object to local time date boundaries which are within the time range of the mts object. This has the effect of removing partial-day data records at the start and end of the timeseries and is useful when calculating full-day statistics.
By default, multi-day periods of all-missing data at the beginning and end
of the timeseries are removed before trimming to date boundaries. If
trimEmptyDays = FALSE
all records are retained except for partial days
beyond the first and after the last date boundary.
Day boundaries are calculated using the specified timezone
or, if
NULL
, mts$meta$timezone
. Leaving timezone = NULL
, the
default, results in "local time" date filtering which is the most
common use case.
mts_trimDate(mts = NULL, timezone = NULL, trimEmptyDays = TRUE)
mts |
mts object. |
timezone |
Olson timezone used to interpret dates. |
trimEmptyDays |
Logical specifying whether to remove days with no data at the beginning and end of the time range. |
A subset of the incoming mts time series object.
(A list with meta
and data
dataframes.)
library(MazamaTimeSeries)
UTC_week <- mts_filterDate(
example_mts,
startdate = 20190703,
enddate = 20190706,
timezone = "UTC"
)
# UTC day boundaries
range(UTC_week$data$datetime)
# Trim to local time day boundaries
local_week <- mts_trimDate(UTC_week)
range(local_week$data$datetime)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.