R/monitor_replaceValues.R
monitor_replaceValues.Rd
Use an R expression to identify values for replacement.
The R expression given in filter
is used to identify elements
in monitor$data
that should be replaced. The datetime
column
will be retained unmodified. Typical usage would include
replacing negative values with 0
replacing unreasonably high values with NA
Expressions should use data
for the left hand side of the comparison.
monitor_replaceValues(monitor = NULL, filter = NULL, value = NULL)
mts_monitor object.
R expression used to identify values for replacement.
Numeric replacement value.
A modified mts_monitor
object. (A list with
meta
and data
dataframes.)
library(AirMonitor)
wa <- monitor_filterMeta(NW_Megafires, stateCode == 'WA')
any(wa$data < 5, na.rm = TRUE)
#> [1] TRUE
wa_zero <- monitor_replaceValues(wa, data < 5, 5)
any(wa_zero$data < 5, na.rm = TRUE)
#> [1] FALSE