A generalized metadata filter for mts_monitor objects to choose cases where conditions are true. Multiple conditions are combined with & or separated by a comma. Only rows where the condition evaluates to TRUE are kept. Rows of monitor$meta where the condition evaluates to NA are dropped. Associated olumns of monitor$data are also dropped for internal consistency in the returned mts_monitor object.

monitor_filter() is an alias for monitor_filterMeta().

monitor_filterMeta(monitor, ...)

monitor_filter(monitor, ...)

Arguments

monitor

mts_monitor object.

...

Logical predicates defined in terms of the variables in monitor$meta.

Value

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

Note

Filtering is done on variables in monitor$meta.

Examples

library(AirMonitor)

# Filter based on countyName field
Camp_Fire %>%
  monitor_filter(countyName == "Alameda") %>%
  monitor_timeseriesPlot(main = "All Alameda County Monitors")


# Filter combining two fields
Camp_Fire %>%
  monitor_filter(latitude > 39.5, longitude > -121.5) %>%
  monitor_pull("locationName")
#> [1] "MMCA81017"   "Portola"     "Quincy BAM"  "Chester BAM" "MMCA81019"  

# Filter using string matching
Camp_Fire %>%
  monitor_filter(stringr::str_detect(locationName, "^San")) %>%
  monitor_pull("locationName")
#>  [1] "Santa Cruz AMS"         "Santa Clarita"          "San Rafael"            
#>  [4] "Santa Barbara"          "Santa Maria - Broadway" "San Francisco"         
#>  [7] "San Pablo - Rumrill"    "San Jose - Jackson St." "San Jose - Knox Ave"   
#> [10] "San Andreas"