sts_filterDatetime {MazamaTimeSeries}R Documentation

Datetime filtering for sts time series objects

Description

Subsets a MazamaSingleTimeseries object by datetime. This function allows for sub-day filtering as opposed to sts_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.

  1. get timezone from startdate if it is POSIXct

  2. use passed in timezone

  3. get timezone from sts

Usage

sts_filterDatetime(
  sts = NULL,
  startdate = NULL,
  enddate = NULL,
  timezone = NULL,
  unit = "sec",
  ceilingStart = FALSE,
  ceilingEnd = FALSE,
  includeEnd = FALSE
)

Arguments

sts

MazamaSingleTimeseries sts 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 ceiling_date to the startdate rather than floor_date

ceilingEnd

Logical instruction to apply ceiling_date to the enddate rather than floor_date

includeEnd

Logical specifying that records associated with enddate should be included.

Value

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

Note

The returned sts object will contain data running from the beginning of startdate until the beginning of enddatei.e. no values associated with enddate will be returned. To include enddate you can specify includeEnd = TRUE.

See Also

sts_filter

sts_filterDate

Examples

library(MazamaTimeSeries)

example_sts %>%
  sts_filterDatetime(
    startdate = "2018-08-08 06:00:00",
    enddate = "2018-08-14 18:00:00"
  ) %>%
  sts_extractData() %>%
  head()


[Package MazamaTimeSeries version 0.3.0 Index]