Subsets an mts
object by datetime. This function
allows for sub-day filtering as opposed to mts_filterDate()
which
always filters to day-boundaries.
Datetimes can be anything that is understood by
MazamaCoreUtils::parseDatetime()
. For non-POSIXct
values,
the recommended format is "YYYY-mm-dd HH:MM:SS"
.
Timezone determination precedence assumes that if you are passing in
POSIXct
values then you know what you are doing:
get timezone from startdate
if it is POSIXct
use passed in timezone
get timezone from mts
mts_filterDatetime( mts = NULL, startdate = NULL, enddate = NULL, timezone = NULL, unit = "sec", ceilingStart = FALSE, ceilingEnd = FALSE )
mts | mts object. |
---|---|
startdate | Desired start datetime (ISO 8601). |
enddate | Desired end datetime (ISO 8601). |
timezone | Olson timezone used to interpret dates. |
unit | Units used to determine time at end-of-day. |
ceilingStart | Logical instruction to apply
|
ceilingEnd | Logical instruction to apply
|
A subset of the incoming mts time series object.
(A list with meta
and data
dataframes.)
library(MazamaTimeSeries) example_mts %>% mts_filterDatetime( startdate = "2019-07-03 06:00:00", enddate = "2019-07-06 18:00:00" ) %>% mts_extractData() %>% dplyr::pull(datetime) %>% range()#> [1] "2019-07-03 13:00:00 UTC" "2019-07-07 00:00:00 UTC"