R/monitor_selectWhere.R
monitor_selectWhere.Rd
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
.
monitor_selectWhere(monitor, FUN)
mts_monitor object.
A function applied to time series data that returns TRUE or FALSE.
A subset of the incoming mts_monitor object. (A list with
meta
and data
dataframes.)
library(AirMonitor)
# Show all Camp_Fire locations
Camp_Fire$meta$locationName
#> [1] "Ukiah Library"
#> [2] "MMCA82037"
#> [3] "MMCA81011"
#> [4] "Gilory - 9th Street"
#> [5] "MMCA82006"
#> [6] "Fresno - Garland"
#> [7] "MMNPS1033"
#> [8] "Unit1051"
#> [9] "Kennedy Meadows"
#> [10] "MMCA81020"
#> [11] "Santa Cruz AMS"
#> [12] "Tahoe City"
#> [13] "Unit1045"
#> [14] "MMNPS1038"
#> [15] "Pinehurst"
#> [16] "MMNPS1030"
#> [17] "MMNPS1031"
#> [18] "MMCA81031"
#> [19] "Atascadero2"
#> [20] "MMNPS1016"
#> [21] "Huron"
#> [22] "King City AMS"
#> [23] "Colusa - Sunrise Blvd."
#> [24] "Santa Clarita"
#> [25] "Davis - UCD Campus"
#> [26] "Ojai - Ojai Ave."
#> [27] "Red Bluff"
#> [28] "Willows-Colusa"
#> [29] "MMCA81017"
#> [30] "Sloughhouse"
#> [31] "Livermore - Rincon"
#> [32] NA
#> [33] "Folsom"
#> [34] "Weaverville"
#> [35] "Lebec"
#> [36] "MMFS10401"
#> [37] "Lancaster-Division"
#> [38] "Cortina Rancheria"
#> [39] "El Rio - Rio Mesa School #2"
#> [40] "Lake Elsinore - W. Flint Street"
#> [41] "Hollister AMS"
#> [42] "Piru - Pacific"
#> [43] "San Rafael"
#> [44] "Lompoc H Street"
#> [45] "Nipomo Mesa CDF"
#> [46] "Santa Barbara"
#> [47] "Crestline - Lake Gregory"
#> [48] "Sebastopol"
#> [49] "Santa Maria - Broadway"
#> [50] "MMCA81041"
#> [51] "MariposaUnit1000"
#> [52] "Keeler"
#> [53] "Alpine"
#> [54] "Redwood City"
#> [55] "Tranquillity"
#> [56] "Salinas AMS"
#> [57] "Thousand Oaks - Moorpark Road"
#> [58] "Anaheim"
#> [59] "Goleta"
#> [60] "Simi Valley - Cochran Street"
#> [61] "Upland"
#> [62] "Joshua Tree NP - Cottonwood Canyon 2"
#> [63] "Temecula (Lake Skinner)"
#> [64] "Bakersfield - California Ave"
#> [65] "Laney College"
#> [66] "Vacaville"
#> [67] "Carmel Valley AMS"
#> [68] "Yosemite Village - Visitor Center"
#> [69] "Mira Loma - Van Buren"
#> [70] "Pleasanton - Owens Ct."
#> [71] "Banning - South Hathaway Street"
#> [72] "Calexico - Ethel Street"
#> [73] "San Francisco"
#> [74] "Concord"
#> [75] "Chico - East"
#> [76] "SLV Middle School AMS"
#> [77] "Arden Arcade - Del Paso Manor"
#> [78] "Roseville - N.Sunrise/Douglas"
#> [79] "Elk Grove"
#> [80] "Modesto - 14th Street"
#> [81] "Lee Vining"
#> [82] "Sequoia and Kings Canyon - Ash Mountain"
#> [83] "Woodland"
#> [84] "Rio Vista"
#> [85] "Turlock - S. Minaret Street"
#> [86] "Victorville - Park Avenue"
#> [87] "Oakland West"
#> [88] "Oakland"
#> [89] "Camp Pendleton"
#> [90] "San Pablo - Rumrill"
#> [91] "Reseda"
#> [92] "NCORE - Bishop"
#> [93] "San Jose - Jackson St."
#> [94] "Madera-City"
#> [95] "Portola"
#> [96] "Quincy BAM"
#> [97] "Otay Mesa - Donovan"
#> [98] "San Jose - Knox Ave"
#> [99] "Grass Valley"
#> [100] "TracyAP"
#> [101] "Berkeley Aquatic Park"
#> [102] "Mesa 2 /Nipomo"
#> [103] "Truckee BAM"
#> [104] "Yreka"
#> [105] "Glendora - Laurel"
#> [106] "Porterville-NFS"
#> [107] "Gridley"
#> [108] "Vallejo"
#> [109] "Lone Pine Paiute/Shoshone Tribe-CA"
#> [110] "Yuba City"
#> [111] "Colfax"
#> [112] "Anderson"
#> [113] "Chester BAM"
#> [114] "Merced - S. Coffee Ave"
#> [115] "San Andreas"
#> [116] "MMCA81044"
#> [117] "Paradise Theater"
#> [118] "MMNPS1034"
#> [119] "MMNPS1027"
#> [120] "MMCA81049"
#> [121] "Devil's Postpile"
#> [122] "MMNPS1024"
#> [123] "MMNPS1036"
#> [124] "Springville"
#> [125] "MMCA81021"
#> [126] "MMCA81019"
#> [127] "MMNPS1029"
#> [128] "LCAQMD1001"
#> [129] "Unit1044"
#> [130] "Unit1019"
#> [131] "ARB 1011 (Offline)"
#> [132] "ARB 1020 (offline)"
#> [133] "ARB 1020 (offline)"
#> [134] "ARB 1023 (offline)"
# 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
#> [1] "Ukiah Library" "MMCA81020"
#> [3] "Colusa - Sunrise Blvd." "Davis - UCD Campus"
#> [5] "Willows-Colusa" "Sloughhouse"
#> [7] "Livermore - Rincon" NA
#> [9] "Folsom" "El Rio - Rio Mesa School #2"
#> [11] "Sebastopol" "MMCA81041"
#> [13] "Salinas AMS" "Pleasanton - Owens Ct."
#> [15] "Chico - East" "Arden Arcade - Del Paso Manor"
#> [17] "Roseville - N.Sunrise/Douglas" "Elk Grove"
#> [19] "Modesto - 14th Street" "Woodland"
#> [21] "Rio Vista" "Turlock - S. Minaret Street"
#> [23] "San Pablo - Rumrill" "Grass Valley"
#> [25] "TracyAP" "Gridley"
#> [27] "Yuba City" "Colfax"
#> [29] "Anderson" "MMCA81049"
#> [31] "Devil's Postpile" "MMCA81021"
#> [33] "MMCA81019" "MMNPS1029"
#> [35] "Unit1019" "ARB 1020 (offline)"
#> [37] "ARB 1020 (offline)" "ARB 1023 (offline)"