monitor_selectWhere: Data-based subsetting of time series within an _mts_monitor_...

View source: R/monitor_selectWhere.R

monitor_selectWhereR Documentation

Data-based subsetting of time series within an mts_monitor object.

Description

Subsetting of monitor acts similarly to tidyselect::where() working on monitor$data. The returned mts_monitor object will contain only those time series where FUN applied to the time series data returns TRUE.

Usage

monitor_selectWhere(monitor, FUN)

Arguments

monitor

mts_monitor object.

FUN

A function applied to time series data that returns TRUE or FALSE.

Value

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

See Also

monitor_select

Examples

library(AirMonitor)

# Show all Camp_Fire locations
Camp_Fire$meta$locationName

# Use package US_AQI data for HAZARDOUS
name <- US_AQI$names_eng[6]
threshold <- US_AQI$breaks_PM2.5[6]

# Find HAZARDOUS locations
worst_sites <-
  Camp_Fire %>%
  monitor_selectWhere(
    function(x) { any(x >= threshold, na.rm = TRUE) }
  )

# Show the worst locations
worst_sites$meta$locationName


AirMonitor documentation built on Aug. 26, 2023, 1:08 a.m.