monitor_slice_head {AirMonitor}R Documentation

Subset time series based on their position within an mts_monitor object

Description

An mts_monitor object is reduced so as to contain only the first or last n timeseries. These functions work similarly to dplyr::slice_head and dplyr::slice_tail but apply to both dataframes in the mts_monitor object.

This is primarily useful when the mts_monitor object has been ordered by a previous call to monitor_arrange or by some other means.

monitor_slice_head() selects the first and monitor_slice_tail() the last timeseries in the object.

Usage

monitor_slice_head(monitor, n = 5)

monitor_slice_tail(monitor, n = 5)

Arguments

monitor

mts_monitor object.

n

Number of rows of monitor$meta to select.

Value

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

Examples

library(AirMonitor)

# Find lowest elevation sites
Camp_Fire %>%
  monitor_filter(!is.na(elevation)) %>%
  monitor_arrange(elevation) %>%
  monitor_slice_head(n = 5) %>%
  monitor_getMeta() %>%
  dplyr::select(elevation, locationName)

# Find highest elevation sites
Camp_Fire %>%
  monitor_filterMeta(!is.na(elevation)) %>%
  monitor_arrange(elevation) %>%
  monitor_slice_tail(n = 5) %>%
  monitor_getMeta() %>%
  dplyr::select(elevation, locationName)


[Package AirMonitor version 0.4.0 Index]