mts_filterDate {MazamaTimeSeries}R Documentation

Date filtering for mts time series objects

Description

Subsets an mts object by date. This function always filters to day-boundaries. For sub-day filtering, use mts_setTimeAxis().

Dates can be anything that is understood by MazamaCoreUtils::parseDatetime() including either of the following recommended formats:

Timezone determination precedence assumes that if you are passing in POSIXct values then you know what you are doing:

  1. get timezone from startdate if it is POSIXct

  2. use passed in timezone

  3. get timezone from mts

Usage

mts_filterDate(
  mts = NULL,
  startdate = NULL,
  enddate = NULL,
  timezone = NULL,
  unit = "sec",
  ceilingStart = FALSE,
  ceilingEnd = FALSE
)

Arguments

mts

mts object.

startdate

Desired start date (ISO 8601).

enddate

Desired end date (ISO 8601).

timezone

Olson timezone used to interpret dates.

unit

Units used to determine time at end-of-day.

ceilingStart

Logical instruction to apply ceiling_date to the startdate rather than floor_date.

ceilingEnd

Logical instruction to apply ceiling_date to the enddate rather than floor_date.

Value

A subset of the incoming mts time series object. (A list with meta and data dataframes.)

Note

The returned data will run from the beginning of startdate until the beginning of enddatei.e. no values associated with enddate will be returned. The exception being when enddate is less than 24 hours after startdate. In that case, a single day is returned.

See Also

mts_setTimeAxis

Examples

library(MazamaTimeSeries)

example_mts %>%
  mts_filterDate(
    startdate = 20190703,
    enddate = 20190706
  ) %>%
  mts_extractData() %>%
  dplyr::pull(datetime) %>%
  range()


[Package MazamaTimeSeries version 0.3.0 Index]