monitor_setTimeAxis {AirMonitor}R Documentation

Extend/contract mts_monitor time series to new start and end times

Description

Extends or contracts the time range of an mts_monitor object by adding/removing time steps at the start and end and filling any new time steps with missing values. The resulting time axis is guaranteed to be a regular, hourly axis with no gaps using the same timezone as the incoming mts_monitor object. This is useful when you want to place separate mts_monitor objects on the same time axis for plotting.

If either startdate or enddate is missing, the start or end of the timeseries in monitor will be used.

Usage

monitor_setTimeAxis(
  monitor = NULL,
  startdate = NULL,
  enddate = NULL,
  timezone = NULL
)

Arguments

monitor

mts_monitor object.

startdate

Desired start date (ISO 8601).

enddate

Desired end date (ISO 8601).

timezone

Olson timezone used to interpret startdate and enddate.

Value

The incoming mts_monitor time series object defined on a new time axis. (A list with meta and data dataframes.)

Note

If startdate or enddate is a POSIXct value, then timezone will be set to the timezone associated with startdate or enddate. In this common case, you don't need to specify timezone explicitly.

If neither startdate nor enddate is a POSIXct value AND no timezone is supplied, the timezone will be inferred from the most common timezone found in monitor.

Examples

library(AirMonitor)

# Default range
Carmel_Valley %>%
  monitor_timeRange()

# One-sided extend with user specified timezone
Carmel_Valley %>%
  monitor_setTimeAxis(enddate = 20160820, timezone = "UTC") %>%
  monitor_timeRange()

# Two-sided extend with user specified timezone
Carmel_Valley %>%
  monitor_setTimeAxis(20190720, 20190820, timezone = "UTC") %>%
  monitor_timeRange()

# Two-sided extend without timezone (uses monitor$meta$timezone)
Carmel_Valley %>%
  monitor_setTimeAxis(20190720, 20190820) %>%
  monitor_timeRange()


[Package AirMonitor version 0.4.0 Index]