diff --git a/DESCRIPTION b/DESCRIPTION
index 6322645..5097f74 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Type: Package
Package: AirMonitor
-Version: 0.3.1
+Version: 0.3.2
Title: Air Quality Data Analysis
Authors@R: c(
person("Jonathan", "Callahan", email="jonathan.s.callahan@gmail.com", role=c("aut","cre")),
diff --git a/NAMESPACE b/NAMESPACE
index ece691c..490720a 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -51,6 +51,7 @@ export(monitor_nowcast)
export(monitor_reorder)
export(monitor_replaceValues)
export(monitor_select)
+export(monitor_selectWhere)
export(monitor_timeInfo)
export(monitor_timeRange)
export(monitor_timeseriesPlot)
diff --git a/NEWS.md b/NEWS.md
index 14c5bf9..d07a282 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,7 @@
+# AirMonitor 0.3.2
+
+* Added `monitor_selectWhere()` for data based selection.
+
# AirMonitor 0.3.1
* Updated `monitor_toPWFSLSmoke()` and `monitor_fromPWFSLSmoke()` to support
diff --git a/R/monitor_selectWhere.R b/R/monitor_selectWhere.R
new file mode 100644
index 0000000..74daae0
--- /dev/null
+++ b/R/monitor_selectWhere.R
@@ -0,0 +1,92 @@
+#' @export
+#' @importFrom rlang .data
+#'
+#' @title Data-based subsetting of time series within an \emph{mts_monitor} object.
+#'
+#' @param monitor \emph{mts_monitor} object.
+#' @param FUN A function applied to time series data that returns TRUE or FALSE.
+#'
+#' @description
+#' Subsetting of \code{monitor} acts similarly to \code{tidyselect::where()} working on
+#' \code{monitor$data}. The returned \emph{mts_monitor} object will contain only
+#' those time series where \code{FUN} applied to the time series data returns \code{TRUE}.
+#'
+#' @return A subset of the incoming \emph{mts_monitor} object. (A list with
+#' \code{meta} and \code{data} dataframes.)
+#'
+#' @seealso \link{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
+#'
+
+monitor_selectWhere <- function(
+ monitor,
+ FUN
+) {
+
+ # ----- Validate parameters --------------------------------------------------
+
+ # A little involved to catch the case where the user forgets to pass in 'monitor'
+ result <- try({
+ if ( !monitor_isValid(monitor) )
+ stop("First argument is not a valid 'mts_monitor' object.")
+ }, silent = TRUE)
+
+ if ( class(result) %in% "try-error" ) {
+ err_msg <- geterrmessage()
+ if ( stringr::str_detect(err_msg, "object .* not found") ) {
+ stop(paste0(err_msg, "\n(Did you forget to pass in the 'monitor' object?)"))
+ }
+ }
+
+ if ( monitor_isEmpty(monitor) )
+ stop("Parameter 'monitor' has no data.")
+
+ if ( !is.function(FUN) )
+ stop("'FUN' is not a function.")
+
+ if ( !is.logical(FUN(c(1:5,NA,6:10))) )
+ stop("'FUN' does not return a logical value. Do you need to include 'na.rm = TRUE'?")
+
+ # ----- Apply function -------------------------------------------------------
+
+ # See https://dplyr.tidyverse.org/articles/colwise.html
+
+ # Get dataBrick
+ tbl <- monitor$data[,-1]
+
+ # Apply function
+ mask <-
+ tbl %>%
+ dplyr::summarize(dplyr::across(.cols = dplyr::everything(), FUN)) %>%
+ as.logical()
+
+ # Get deviceDeploymentIDs where FUN returns TRUE
+ ids <- names(tbl)[mask]
+
+ # Select those monitors
+ monitor <- monitor %>% monitor_select(ids)
+
+ # ----- Return ---------------------------------------------------------------
+
+ return(invisible(monitor))
+
+}
diff --git a/docs/404.html b/docs/404.html
index ea50e04..03a791f 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -71,7 +71,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html
index 889ce3b..06d8f86 100644
--- a/docs/LICENSE-text.html
+++ b/docs/LICENSE-text.html
@@ -71,7 +71,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/articles/AirMonitor.html b/docs/articles/AirMonitor.html
index 439765c..fa02447 100644
--- a/docs/articles/AirMonitor.html
+++ b/docs/articles/AirMonitor.html
@@ -31,7 +31,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
@@ -170,8 +170,8 @@
to get it’s deviceDeploymentID
:
-
-We can use this deviceDeploymentID
to create a
+
+We can use this deviceDeploymentID
to create a
mts_monitor object for this single monitor and take a look at a
timeseries plot:
-
-We can display the hourly data for all the monitors and add day/night
+
+We can display the hourly data for all the monitors and add day/night
shading:
Sacramento_area %>%
diff --git a/docs/articles/Data_Model.html b/docs/articles/Data_Model.html
index f27f15b..4059d3c 100644
--- a/docs/articles/Data_Model.html
+++ b/docs/articles/Data_Model.html
@@ -31,7 +31,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/articles/Developer_Style_Guide.html b/docs/articles/Developer_Style_Guide.html
index 23b89d0..7c2eceb 100644
--- a/docs/articles/Developer_Style_Guide.html
+++ b/docs/articles/Developer_Style_Guide.html
@@ -31,7 +31,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/articles/articles/Citations.html b/docs/articles/articles/Citations.html
index 890a00e..d2e89fc 100644
--- a/docs/articles/articles/Citations.html
+++ b/docs/articles/articles/Citations.html
@@ -31,7 +31,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/articles/index.html b/docs/articles/index.html
index d412dd0..ca40b3f 100644
--- a/docs/articles/index.html
+++ b/docs/articles/index.html
@@ -71,7 +71,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/authors.html b/docs/authors.html
index 8dfc54b..2988e8c 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -71,7 +71,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/index.html b/docs/index.html
index 475b855..1cb2e75 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -39,7 +39,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/news/index.html b/docs/news/index.html
index be67109..7110132 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -71,7 +71,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
@@ -135,6 +135,15 @@ Changelog
Source: NEWS.md
+
diff --git a/docs/reference/AirMonitor.html b/docs/reference/AirMonitor.html
index d3240a8..00b5b4d 100644
--- a/docs/reference/AirMonitor.html
+++ b/docs/reference/AirMonitor.html
@@ -79,7 +79,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/CONUS.html b/docs/reference/CONUS.html
index 22333ff..21dd9fc 100644
--- a/docs/reference/CONUS.html
+++ b/docs/reference/CONUS.html
@@ -82,7 +82,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/Camp_Fire.html b/docs/reference/Camp_Fire.html
index dd76851..9c2f8c9 100644
--- a/docs/reference/Camp_Fire.html
+++ b/docs/reference/Camp_Fire.html
@@ -73,7 +73,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/Carmel_Valley.html b/docs/reference/Carmel_Valley.html
index 91962dd..89dd735 100644
--- a/docs/reference/Carmel_Valley.html
+++ b/docs/reference/Carmel_Valley.html
@@ -73,7 +73,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/NW_Megafires.html b/docs/reference/NW_Megafires.html
index 0bce785..368394f 100644
--- a/docs/reference/NW_Megafires.html
+++ b/docs/reference/NW_Megafires.html
@@ -73,7 +73,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/US_52.html b/docs/reference/US_52.html
index 1cc62e7..2a19d2c 100644
--- a/docs/reference/US_52.html
+++ b/docs/reference/US_52.html
@@ -82,7 +82,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/US_AQI.html b/docs/reference/US_AQI.html
index e669c5d..d9fbdb0 100644
--- a/docs/reference/US_AQI.html
+++ b/docs/reference/US_AQI.html
@@ -73,7 +73,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/addAQILegend.html b/docs/reference/addAQILegend.html
index ddf7b3d..a93064c 100644
--- a/docs/reference/addAQILegend.html
+++ b/docs/reference/addAQILegend.html
@@ -78,7 +78,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/addAQILines.html b/docs/reference/addAQILines.html
index fcc6720..d3fc503 100644
--- a/docs/reference/addAQILines.html
+++ b/docs/reference/addAQILines.html
@@ -75,7 +75,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/addAQIStackedBar.html b/docs/reference/addAQIStackedBar.html
index 31a0aa0..f87adac 100644
--- a/docs/reference/addAQIStackedBar.html
+++ b/docs/reference/addAQIStackedBar.html
@@ -74,7 +74,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/addShadedNight.html b/docs/reference/addShadedNight.html
index 04e4feb..693c1e4 100644
--- a/docs/reference/addShadedNight.html
+++ b/docs/reference/addShadedNight.html
@@ -74,7 +74,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/airnow_loadAnnual.html b/docs/reference/airnow_loadAnnual.html
index aec6450..bdb97cf 100644
--- a/docs/reference/airnow_loadAnnual.html
+++ b/docs/reference/airnow_loadAnnual.html
@@ -83,7 +83,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/airnow_loadDaily.html b/docs/reference/airnow_loadDaily.html
index 34319f7..34b1ed7 100644
--- a/docs/reference/airnow_loadDaily.html
+++ b/docs/reference/airnow_loadDaily.html
@@ -85,7 +85,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/airnow_loadLatest.html b/docs/reference/airnow_loadLatest.html
index 00a1d18..1736e9b 100644
--- a/docs/reference/airnow_loadLatest.html
+++ b/docs/reference/airnow_loadLatest.html
@@ -85,7 +85,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/airnow_loadMonthly.html b/docs/reference/airnow_loadMonthly.html
index 4711411..6646221 100644
--- a/docs/reference/airnow_loadMonthly.html
+++ b/docs/reference/airnow_loadMonthly.html
@@ -84,7 +84,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/airsis_loadAnnual.html b/docs/reference/airsis_loadAnnual.html
index 3a76eec..b3b5a13 100644
--- a/docs/reference/airsis_loadAnnual.html
+++ b/docs/reference/airsis_loadAnnual.html
@@ -79,7 +79,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/airsis_loadDaily.html b/docs/reference/airsis_loadDaily.html
index 7bf11d0..f68b306 100644
--- a/docs/reference/airsis_loadDaily.html
+++ b/docs/reference/airsis_loadDaily.html
@@ -80,7 +80,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/airsis_loadLatest.html b/docs/reference/airsis_loadLatest.html
index 8570339..1378b9a 100644
--- a/docs/reference/airsis_loadLatest.html
+++ b/docs/reference/airsis_loadLatest.html
@@ -80,7 +80,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/aqiColors.html b/docs/reference/aqiColors.html
index ebf600a..bb509d9 100644
--- a/docs/reference/aqiColors.html
+++ b/docs/reference/aqiColors.html
@@ -73,7 +73,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/coreMetadataNames.html b/docs/reference/coreMetadataNames.html
index e98e463..07d1dfc 100644
--- a/docs/reference/coreMetadataNames.html
+++ b/docs/reference/coreMetadataNames.html
@@ -74,7 +74,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 0304107..dda1eb8 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -71,7 +71,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
@@ -462,6 +462,12 @@ monitor_selectWhere()
+
+ Data-based subsetting of time series within an mts_monitor object.
+
+
monitor_timeInfo()
diff --git a/docs/reference/monitor_aqi.html b/docs/reference/monitor_aqi.html
index 3da7ebb..31d9984 100644
--- a/docs/reference/monitor_aqi.html
+++ b/docs/reference/monitor_aqi.html
@@ -74,7 +74,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_bestTimezone.html b/docs/reference/monitor_bestTimezone.html
index 81b2ddc..b485d09 100644
--- a/docs/reference/monitor_bestTimezone.html
+++ b/docs/reference/monitor_bestTimezone.html
@@ -74,7 +74,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_check.html b/docs/reference/monitor_check.html
index ccadd01..b15ca08 100644
--- a/docs/reference/monitor_check.html
+++ b/docs/reference/monitor_check.html
@@ -73,7 +73,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_collapse.html b/docs/reference/monitor_collapse.html
index 75cf636..3513297 100644
--- a/docs/reference/monitor_collapse.html
+++ b/docs/reference/monitor_collapse.html
@@ -83,7 +83,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_combine.html b/docs/reference/monitor_combine.html
index df3549a..3af12bc 100644
--- a/docs/reference/monitor_combine.html
+++ b/docs/reference/monitor_combine.html
@@ -81,7 +81,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_dailyBarplot.html b/docs/reference/monitor_dailyBarplot.html
index 02a9c83..468cb78 100644
--- a/docs/reference/monitor_dailyBarplot.html
+++ b/docs/reference/monitor_dailyBarplot.html
@@ -75,7 +75,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_dailyStatistic.html b/docs/reference/monitor_dailyStatistic.html
index 92e18f8..110b3cc 100644
--- a/docs/reference/monitor_dailyStatistic.html
+++ b/docs/reference/monitor_dailyStatistic.html
@@ -76,7 +76,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_dailyThreshold.html b/docs/reference/monitor_dailyThreshold.html
index 146ec58..bfb435c 100644
--- a/docs/reference/monitor_dailyThreshold.html
+++ b/docs/reference/monitor_dailyThreshold.html
@@ -76,7 +76,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_distinct.html b/docs/reference/monitor_distinct.html
index d4ea935..81f20f4 100644
--- a/docs/reference/monitor_distinct.html
+++ b/docs/reference/monitor_distinct.html
@@ -78,7 +78,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_dropEmpty.html b/docs/reference/monitor_dropEmpty.html
index a93a50d..16161bd 100644
--- a/docs/reference/monitor_dropEmpty.html
+++ b/docs/reference/monitor_dropEmpty.html
@@ -73,7 +73,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_dygraph.html b/docs/reference/monitor_dygraph.html
index d53b77a..9fc252c 100644
--- a/docs/reference/monitor_dygraph.html
+++ b/docs/reference/monitor_dygraph.html
@@ -73,7 +73,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_filterByDistance.html b/docs/reference/monitor_filterByDistance.html
index 7e21eaf..b70b207 100644
--- a/docs/reference/monitor_filterByDistance.html
+++ b/docs/reference/monitor_filterByDistance.html
@@ -80,7 +80,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_filterDate.html b/docs/reference/monitor_filterDate.html
index f8b1117..9df00da 100644
--- a/docs/reference/monitor_filterDate.html
+++ b/docs/reference/monitor_filterDate.html
@@ -91,7 +91,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_filterDatetime.html b/docs/reference/monitor_filterDatetime.html
index 3bf0fd6..1046592 100644
--- a/docs/reference/monitor_filterDatetime.html
+++ b/docs/reference/monitor_filterDatetime.html
@@ -87,7 +87,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_filterMeta.html b/docs/reference/monitor_filterMeta.html
index 78fa979..db6c871 100644
--- a/docs/reference/monitor_filterMeta.html
+++ b/docs/reference/monitor_filterMeta.html
@@ -79,7 +79,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_fromPWFSLSmoke.html b/docs/reference/monitor_fromPWFSLSmoke.html
index b2001cb..2778dac 100644
--- a/docs/reference/monitor_fromPWFSLSmoke.html
+++ b/docs/reference/monitor_fromPWFSLSmoke.html
@@ -74,7 +74,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_getCurrentStatus.html b/docs/reference/monitor_getCurrentStatus.html
index c953761..7692af9 100644
--- a/docs/reference/monitor_getCurrentStatus.html
+++ b/docs/reference/monitor_getCurrentStatus.html
@@ -73,7 +73,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_getDataFrame.html b/docs/reference/monitor_getDataFrame.html
index db07993..78a6df3 100644
--- a/docs/reference/monitor_getDataFrame.html
+++ b/docs/reference/monitor_getDataFrame.html
@@ -82,7 +82,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_getDistance.html b/docs/reference/monitor_getDistance.html
index 8272635..40c4e70 100644
--- a/docs/reference/monitor_getDistance.html
+++ b/docs/reference/monitor_getDistance.html
@@ -74,7 +74,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_isEmpty.html b/docs/reference/monitor_isEmpty.html
index e34d3dd..3dc57c0 100644
--- a/docs/reference/monitor_isEmpty.html
+++ b/docs/reference/monitor_isEmpty.html
@@ -76,7 +76,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_isValid.html b/docs/reference/monitor_isValid.html
index 3bb8dbd..1daf030 100644
--- a/docs/reference/monitor_isValid.html
+++ b/docs/reference/monitor_isValid.html
@@ -92,7 +92,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_leaflet.html b/docs/reference/monitor_leaflet.html
index c7d4bb6..3da8082 100644
--- a/docs/reference/monitor_leaflet.html
+++ b/docs/reference/monitor_leaflet.html
@@ -81,7 +81,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_load.html b/docs/reference/monitor_load.html
index 3eede61..41a9005 100644
--- a/docs/reference/monitor_load.html
+++ b/docs/reference/monitor_load.html
@@ -75,7 +75,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_loadAnnual.html b/docs/reference/monitor_loadAnnual.html
index c2929b1..80d0f6a 100644
--- a/docs/reference/monitor_loadAnnual.html
+++ b/docs/reference/monitor_loadAnnual.html
@@ -79,7 +79,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_loadDaily.html b/docs/reference/monitor_loadDaily.html
index 1e39714..e59a577 100644
--- a/docs/reference/monitor_loadDaily.html
+++ b/docs/reference/monitor_loadDaily.html
@@ -79,7 +79,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_loadLatest.html b/docs/reference/monitor_loadLatest.html
index 5e0c87e..398e347 100644
--- a/docs/reference/monitor_loadLatest.html
+++ b/docs/reference/monitor_loadLatest.html
@@ -79,7 +79,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_mutate.html b/docs/reference/monitor_mutate.html
index 31bf73e..2191168 100644
--- a/docs/reference/monitor_mutate.html
+++ b/docs/reference/monitor_mutate.html
@@ -75,7 +75,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_nowcast.html b/docs/reference/monitor_nowcast.html
index 26e252c..75cd1f6 100644
--- a/docs/reference/monitor_nowcast.html
+++ b/docs/reference/monitor_nowcast.html
@@ -81,7 +81,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_replaceValues.html b/docs/reference/monitor_replaceValues.html
index c26b969..83ac2cc 100644
--- a/docs/reference/monitor_replaceValues.html
+++ b/docs/reference/monitor_replaceValues.html
@@ -81,7 +81,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_select.html b/docs/reference/monitor_select.html
index 9212690..be8841f 100644
--- a/docs/reference/monitor_select.html
+++ b/docs/reference/monitor_select.html
@@ -76,7 +76,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_selectWhere.html b/docs/reference/monitor_selectWhere.html
new file mode 100644
index 0000000..673c817
--- /dev/null
+++ b/docs/reference/monitor_selectWhere.html
@@ -0,0 +1,367 @@
+
+
+
+
+
+
+
+
+Data-based subsetting of time series within an mts_monitor object. — monitor_selectWhere • AirMonitor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 )
+
+
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
+
+
+
+
Examples
+
#> [1] "Livermore - Rincon"
+#> [2] "Oakland"
+#> [3] "Oakland West"
+#> [4] "Laney College"
+#> [5] "Berkeley Aquatic Park"
+#> [6] "Pleasanton - Owens Ct."
+#> [7] "Chico - East"
+#> [8] "Gridley"
+#> [9] "San Andreas"
+#> [10] "Cortina Rancheria"
+#> [11] "Colusa - Sunrise Blvd."
+#> [12] "Concord"
+#> [13] "San Pablo - Rumrill"
+#> [14] "Fresno - Garland"
+#> [15] "Huron"
+#> [16] "Tranquillity"
+#> [17] "Willows-Colusa"
+#> [18] "Calexico - Ethel Street"
+#> [19] "El Centro - 9th Street"
+#> [20] "NCORE - Bishop"
+#> [21] "Keeler"
+#> [22] "Bishop Paiute Tribe-CA"
+#> [23] "Mojave - 923 Poole St."
+#> [24] "Bakersfield - California Ave"
+#> [25] "Lebec"
+#> [26] "Glendora - Laurel"
+#> [27] "Los Angeles - N. Main Street"
+#> [28] "Reseda"
+#> [29] "South Long Beach"
+#> [30] "Santa Clarita"
+#> [31] "Lancaster-Division"
+#> [32] "Madera-City"
+#> [33] "San Rafael"
+#> [34] "Yosemite Village - Visitor Center"
+#> [35] "Ukiah Library"
+#> [36] "Willits Unified School District"
+#> [37] "Merced - S. Coffee Ave"
+#> [38] "Mammoth Lakes"
+#> [39] "Lee Vining"
+#> [40] "Carmel Valley AMS"
+#> [41] "King City AMS"
+#> [42] "Salinas AMS"
+#> [43] "Napa - Napa Valley College"
+#> [44] "Grass Valley"
+#> [45] "Truckee BAM"
+#> [46] "Anaheim"
+#> [47] "Auburn"
+#> [48] "Colfax"
+#> [49] "Tahoe City"
+#> [50] "Lincoln"
+#> [51] "Chester BAM"
+#> [52] "Portola"
+#> [53] "Quincy BAM"
+#> [54] "Joshua Tree NP - Cottonwood Canyon 2"
+#> [55] "Banning - South Hathaway Street"
+#> [56] "Temecula (Lake Skinner)"
+#> [57] "Riverside - Rubidoux"
+#> [58] "Mira Loma - Van Buren"
+#> [59] "Lake Elsinore - W. Flint Street"
+#> [60] "Arden Arcade - Del Paso Manor"
+#> [61] "Downtown Sacramento - T Street"
+#> [62] "Elk Grove"
+#> [63] "Folsom"
+#> [64] "Sloughhouse"
+#> [65] "Hollister AMS"
+#> [66] "Crestline - Lake Gregory"
+#> [67] "Victorville - Park Avenue"
+#> [68] "Upland"
+#> [69] "Alpine"
+#> [70] "Camp Pendleton"
+#> [71] "Otay Mesa - Donovan"
+#> [72] "El Cajon - Lexington Elementary School"
+#> [73] "San Francisco"
+#> [74] "Stockton - Hazelton Street"
+#> [75] "TracyAP"
+#> [76] "Mesa 2 /Nipomo"
+#> [77] "San Luis Obispo - Higuera St"
+#> [78] "Nipomo Mesa CDF"
+#> [79] "Atascadero2"
+#> [80] "Redwood City"
+#> [81] "Santa Barbara"
+#> [82] "Santa Maria - Broadway"
+#> [83] "Lompoc H Street"
+#> [84] "Goleta"
+#> [85] "Gilory - 9th Street"
+#> [86] "San Jose - Jackson St."
+#> [87] "San Jose - Knox Ave"
+#> [88] "Santa Cruz AMS"
+#> [89] "Zayante Fire Station"
+#> [90] "Felton Cal-Fire"
+#> [91] "Boulder Creek"
+#> [92] "Anderson"
+#> [93] "Yreka"
+#> [94] "Vallejo"
+#> [95] "Vacaville"
+#> [96] "Rio Vista"
+#> [97] "Sebastopol"
+#> [98] "Turlock - S. Minaret Street"
+#> [99] "Yuba City"
+#> [100] "Red Bluff - Walnut office"
+#> [101] "Weaverville"
+#> [102] "Sequoia and Kings Canyon - Ash Mountain"
+#> [103] "Visalia - N. Church Street"
+#> [104] "Porterville-NFS"
+#> [105] "Thousand Oaks - Moorpark Road"
+#> [106] "Piru - Pacific"
+#> [107] "Ojai - Ojai Ave."
+#> [108] "Simi Valley - Cochran Street"
+#> [109] "El Rio - Rio Mesa School #2"
+#> [110] "Davis - UCD Campus"
+#> [111] "Woodland"
+#> [112] "EBAM7 - Sac 5th St. Warehouse"
+#> [113] "Pinehurst"
+#> [114] "Kernville"
+#> [115] "Kennedy Meadows"
+#> [116] "Modesto - 14th Street"
+#> [117] "Lone Pine Paiute/Shoshone Tribe-CA"
+#> [118] "SLV Middle School AMS"
+#> [119] "Roseville - N.Sunrise/Douglas"
+#> [120] "Paradise Theater"
+#> [121] "ARB 1017 (offline)"
+#> [122] "LCAQMD1001"
+#> [123] "NPT1002"
+#> [124] "NPT1002"
+#> [125] "1051 Kernville EBAM"
+#> [126] "1060 North Fork"
+#> [127] "ARB 1041 (offline)"
+#> [128] "ARB 1011 (Trinity C)"
+#> [129] "Mariposa 1000"
+#> [130] "SEKI1032 EBAM4"
+#> [131] "ARB 1025 (offline)"
+#> [132] "ARB 1023 (offline)"
+#> [133] "ARB 1010 (offline)"
#> [1] "Livermore - Rincon" "Pleasanton - Owens Ct."
+#> [3] "Chico - East" "Gridley"
+#> [5] "Colusa - Sunrise Blvd." "San Pablo - Rumrill"
+#> [7] "Willows-Colusa" "Ukiah Library"
+#> [9] "Salinas AMS" "Grass Valley"
+#> [11] "Colfax" "Lincoln"
+#> [13] "Arden Arcade - Del Paso Manor" "Downtown Sacramento - T Street"
+#> [15] "Elk Grove" "Folsom"
+#> [17] "Sloughhouse" "Stockton - Hazelton Street"
+#> [19] "TracyAP" "Anderson"
+#> [21] "Rio Vista" "Sebastopol"
+#> [23] "Turlock - S. Minaret Street" "Yuba City"
+#> [25] "El Rio - Rio Mesa School #2" "Davis - UCD Campus"
+#> [27] "Woodland" "Modesto - 14th Street"
+#> [29] "Roseville - N.Sunrise/Douglas" "1060 North Fork"
+#> [31] "ARB 1041 (offline)" "ARB 1023 (offline)"
+#> [33] "ARB 1010 (offline)"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/reference/monitor_timeInfo.html b/docs/reference/monitor_timeInfo.html
index f66a662..600de77 100644
--- a/docs/reference/monitor_timeInfo.html
+++ b/docs/reference/monitor_timeInfo.html
@@ -88,7 +88,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_timeRange.html b/docs/reference/monitor_timeRange.html
index e48facc..df5b3f6 100644
--- a/docs/reference/monitor_timeRange.html
+++ b/docs/reference/monitor_timeRange.html
@@ -76,7 +76,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_timeseriesPlot.html b/docs/reference/monitor_timeseriesPlot.html
index 2adafb2..0a1bd35 100644
--- a/docs/reference/monitor_timeseriesPlot.html
+++ b/docs/reference/monitor_timeseriesPlot.html
@@ -77,7 +77,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_toCSV.html b/docs/reference/monitor_toCSV.html
index 8b0bd1a..16ab737 100644
--- a/docs/reference/monitor_toCSV.html
+++ b/docs/reference/monitor_toCSV.html
@@ -79,7 +79,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_toPWFSLSmoke.html b/docs/reference/monitor_toPWFSLSmoke.html
index c569bbc..bfcf94e 100644
--- a/docs/reference/monitor_toPWFSLSmoke.html
+++ b/docs/reference/monitor_toPWFSLSmoke.html
@@ -74,7 +74,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/monitor_trimDate.html b/docs/reference/monitor_trimDate.html
index a0fa668..f6c8bdf 100644
--- a/docs/reference/monitor_trimDate.html
+++ b/docs/reference/monitor_trimDate.html
@@ -81,7 +81,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/pipe.html b/docs/reference/pipe.html
index 61c1813..7ff59de 100644
--- a/docs/reference/pipe.html
+++ b/docs/reference/pipe.html
@@ -72,7 +72,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/pollutantNames.html b/docs/reference/pollutantNames.html
index cf7ed51..8d31042 100644
--- a/docs/reference/pollutantNames.html
+++ b/docs/reference/pollutantNames.html
@@ -72,7 +72,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/wrcc_loadAnnual.html b/docs/reference/wrcc_loadAnnual.html
index 5ff6762..73cf614 100644
--- a/docs/reference/wrcc_loadAnnual.html
+++ b/docs/reference/wrcc_loadAnnual.html
@@ -79,7 +79,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/wrcc_loadDaily.html b/docs/reference/wrcc_loadDaily.html
index 1d94331..44dfbcf 100644
--- a/docs/reference/wrcc_loadDaily.html
+++ b/docs/reference/wrcc_loadDaily.html
@@ -80,7 +80,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/docs/reference/wrcc_loadLatest.html b/docs/reference/wrcc_loadLatest.html
index c6eb0a7..f138809 100644
--- a/docs/reference/wrcc_loadLatest.html
+++ b/docs/reference/wrcc_loadLatest.html
@@ -80,7 +80,7 @@
AirMonitor
- 0.3.1
+ 0.3.2
diff --git a/local_ASIC/ASIC_2022_AirMonitor.R b/local_ASIC/ASIC_2022_AirMonitor.R
index 2babbaa..8d91538 100644
--- a/local_ASIC/ASIC_2022_AirMonitor.R
+++ b/local_ASIC/ASIC_2022_AirMonitor.R
@@ -24,7 +24,7 @@ latest %>% monitor_leaflet()
# Use the deviceDeploymentID to select a single monitor
monitor <-
latest %>%
- monitor_select("4acfb3843fa942f0_040213015") # Hidden Valley, Arizona
+ monitor_select("4acfb3843fa942f0_021040213015") # Hidden Valley, Arizona
dim(monitor$meta)
dim(monitor$data)
diff --git a/local_reports/AIRSIS_Data_Extremes_2021.Rmd b/local_reports/AIRSIS_Data_Extremes_2021.Rmd
index e2bb858..93a1f50 100644
--- a/local_reports/AIRSIS_Data_Extremes_2021.Rmd
+++ b/local_reports/AIRSIS_Data_Extremes_2021.Rmd
@@ -11,7 +11,7 @@ knitr::opts_chunk$set(echo = TRUE)
library(AirMonitor)
cutoff <- 750
-roc_cutoff <- 200
+roc_cutoff <- 250
airsis <-
airsis_loadAnnual(2021) %>%
@@ -36,14 +36,20 @@ smoke was impacting communities.
```{r all_data_timeseries_plot, echo = FALSE}
par(mar = c(3, 4, 6, 2) + .1)
-monitor_timeseriesPlot(airsis, addAQI = TRUE, xpd = NA, main = "2021 PM2.5 Values")
+monitor_timeseriesPlot(airsis, xpd = NA, main = "2021 PM2.5 Values")
+abline(h = cutoff, col = adjustcolor("gray50", 0.6), lwd = 3)
+xlo <- par("usr")[1]
+xhi <- par("usr")[2]
+text(xlo, cutoff+25, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
par(mar = c(5, 4, 4, 2) + .1)
-addAQILegend("topleft", cex = 0.8)
par(mar = c(3, 4, 6, 2) + .1)
-monitor_timeseriesPlot(airsis, ylim = c(0, 1000), addAQI = TRUE, main = "2021 PM2.5 Values (zoomed in)")
+monitor_timeseriesPlot(airsis, ylim = c(0, 1000), main = "2021 PM2.5 Values (zoomed in)")
+abline(h = cutoff, col = adjustcolor("gray50", 0.6), lwd = 3)
+xlo <- par("usr")[1]
+xhi <- par("usr")[2]
+text(xlo, cutoff+25, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
par(mar = c(5, 4, 4, 2) + .1)
-addAQILegend("topleft", cex = 0.8)
```
## High Value Cutoff = `r cutoff`
@@ -87,7 +93,7 @@ abline(h = cutoff, col = adjustcolor("gray50", 0.6), lwd = 3)
xlo <- par("usr")[1]
xhi <- par("usr")[2]
-text(xlo, 200, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
+text(xlo, cutoff+25, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
```
```{r high_value_timeseries_1, echo = FALSE}
@@ -99,7 +105,7 @@ abline(h = cutoff, col = adjustcolor("gray50", 0.6), lwd = 3)
xlo <- par("usr")[1]
xhi <- par("usr")[2]
-text(xlo, 200, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
+text(xlo, cutoff+25, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
```
```{r high_value_timeseries_2, echo = FALSE}
@@ -111,7 +117,7 @@ abline(h = cutoff, col = adjustcolor("gray50", 0.6), lwd = 3)
xlo <- par("usr")[1]
xhi <- par("usr")[2]
-text(xlo, 200, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
+text(xlo, cutoff+25, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
```
```{r high_value_timeseries_3, echo = FALSE}
@@ -123,7 +129,7 @@ abline(h = cutoff, col = adjustcolor("gray50", 0.6), lwd = 3)
xlo <- par("usr")[1]
xhi <- par("usr")[2]
-text(xlo, 200, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
+text(xlo, cutoff+25, sprintf("%d cutoff", cutoff), pos = 4, adj = c(0, 1))
```
## Rate of Change Cutoff = `r roc_cutoff` ug/m3/hr
diff --git a/local_reports/data_extremes.R b/local_reports/data_extremes.R
new file mode 100644
index 0000000..8d3aee5
--- /dev/null
+++ b/local_reports/data_extremes.R
@@ -0,0 +1,44 @@
+# 2022-09-23
+#
+# Explore data extrems with newly rebuilt AIRSIS data archives
+#
+
+library(AirMonitor)
+
+airsis_2022 <- airsis_loadAnnual(2022)
+airsis_2021 <- airsis_loadAnnual(2021)
+airsis_2020 <- airsis_loadAnnual(2020)
+airsis_2019 <- airsis_loadAnnual(2019)
+airsis_2018 <- airsis_loadAnnual(2018)
+airsis_2017 <- airsis_loadAnnual(2017)
+airsis_2016 <- airsis_loadAnnual(2016)
+airsis_2015 <- airsis_loadAnnual(2015)
+
+
+# ----- Extend airsis_2022 -----------------------------------------------------
+
+# Create a tibble with a regular time axis
+hourlyTbl <- dplyr::tibble(
+ datetime = seq(
+ MazamaCoreUtils::parseDatetime(20220101, timezone = "UTC"),
+ MazamaCoreUtils::parseDatetime(20230101, timezone = "UTC"),,
+ by = "hours")
+)
+
+airsis_2022$data <- dplyr::left_join(hourlyTbl, airsis_2022$data, by = "datetime")
+
+# ----- Plot -------------------------------------------------------------------
+
+layout(matrix(seq(8), ncol = 2, byrow = TRUE))
+par(mar = c(3,4,4,2)+.1)
+monitor_timeseriesPlot(airsis_2022, xlab = "", ylim=c(0, 1500), main = "AIRSIS 2022 data")
+monitor_timeseriesPlot(airsis_2021, xlab = "", ylim=c(0, 1500), main = "AIRSIS 2021 data")
+monitor_timeseriesPlot(airsis_2020, xlab = "", ylim=c(0, 1500), main = "AIRSIS 2020 data")
+monitor_timeseriesPlot(airsis_2019, xlab = "", ylim=c(0, 1500), main = "AIRSIS 2019 data")
+monitor_timeseriesPlot(airsis_2018, xlab = "", ylim=c(0, 1500), main = "AIRSIS 2018 data")
+monitor_timeseriesPlot(airsis_2017, xlab = "", ylim=c(0, 1500), main = "AIRSIS 2017 data")
+monitor_timeseriesPlot(airsis_2016, xlab = "", ylim=c(0, 1500), main = "AIRSIS 2016 data")
+monitor_timeseriesPlot(airsis_2015, xlab = "", ylim=c(0, 1500), main = "AIRSIS 2015 data")
+par(mar = c(5,4,4,2) + .1)
+layout(1)
+
diff --git a/man/monitor_selectWhere.Rd b/man/monitor_selectWhere.Rd
new file mode 100644
index 0000000..f63c0d2
--- /dev/null
+++ b/man/monitor_selectWhere.Rd
@@ -0,0 +1,46 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/monitor_selectWhere.R
+\name{monitor_selectWhere}
+\alias{monitor_selectWhere}
+\title{Data-based subsetting of time series within an \emph{mts_monitor} object.}
+\usage{
+monitor_selectWhere(monitor, FUN)
+}
+\arguments{
+\item{monitor}{\emph{mts_monitor} object.}
+
+\item{FUN}{A function applied to time series data that returns TRUE or FALSE.}
+}
+\value{
+A subset of the incoming \emph{mts_monitor} object. (A list with
+\code{meta} and \code{data} dataframes.)
+}
+\description{
+Subsetting of \code{monitor} acts similarly to \code{tidyselect::where()} working on
+\code{monitor$data}. The returned \emph{mts_monitor} object will contain only
+those time series where \code{FUN} applied to the time series data returns \code{TRUE}.
+}
+\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
+
+}
+\seealso{
+\link{monitor_select}
+}