Learn R Programming

AirMonitor (version 0.4.2)

monitor_setTimeAxis: 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
)

Value

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

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.

Examples

Run this code
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()

Run the code above in your browser using DataLab