This function works similarly to dplyr::mutate() and applies FUN to each time series found in monitor$data. FUN must be a function that accepts a numeric vector as its first argument and returns a vector of the same length.

monitor_mutate(monitor = NULL, FUN = NULL, ...)

Arguments

monitor

mts_monitor object.

FUN

Function used to modify time series.

...

Additional arguments to be passed to FUN.

Value

A modified mts_monitor object. (A list with meta and data dataframes.)

Examples

library(AirMonitor)

Carmel_Valley %>%
  monitor_filterDatetime(2016080207, 2016080212) %>%
  monitor_toCSV(includeMeta = FALSE) %>%
  cat()
#> UTC Time,Local Time,a9572a904a4ed46d_840060530002
#> 2016-08-02 14:00:00 UTC,2016-08-02 07:00:00 PDT,142
#> 2016-08-02 15:00:00 UTC,2016-08-02 08:00:00 PDT,156
#> 2016-08-02 16:00:00 UTC,2016-08-02 09:00:00 PDT,129
#> 2016-08-02 17:00:00 UTC,2016-08-02 10:00:00 PDT,NA
#> 2016-08-02 18:00:00 UTC,2016-08-02 11:00:00 PDT,100

Carmel_Valley %>%
  monitor_filterDatetime(2016080207, 2016080212) %>%
  monitor_mutate(function(x) { return(x / 2) }) %>%
  monitor_toCSV(includeMeta = FALSE) %>%
  cat()
#> UTC Time,Local Time,a9572a904a4ed46d_840060530002
#> 2016-08-02 14:00:00 UTC,2016-08-02 07:00:00 PDT,71
#> 2016-08-02 15:00:00 UTC,2016-08-02 08:00:00 PDT,78
#> 2016-08-02 16:00:00 UTC,2016-08-02 09:00:00 PDT,64.5
#> 2016-08-02 17:00:00 UTC,2016-08-02 10:00:00 PDT,NA
#> 2016-08-02 18:00:00 UTC,2016-08-02 11:00:00 PDT,50