monitor_collapse: Collapse a ws_monitor Object into a ws_monitor Object with a...

Description Usage Arguments Value Note Examples

View source: R/monitor_collapse.R

Description

Collapses data from all the monitors in ws_monitor into a single-monitor ws_monitor object using the function provided in the FUN argument. The single-monitor result will be located at the mean longitude and latitude unless longitude and latitude parameters are specified.

Any columns of meta that are common to all monitors will be retained in the returned ws_monitor meta.

Usage

1
2
3
4
5
6
7
8
9
monitor_collapse(
  ws_monitor,
  longitude = NULL,
  latitude = NULL,
  monitorID = "generated_id",
  FUN = mean,
  na.rm = TRUE,
  ...
)

Arguments

ws_monitor

ws_monitor object.

longitude

Longitude of the collapsed monitoring station.

latitude

Latitude of the collapsed monitoring station.

monitorID

Monitor ID assigned to the collapsed monitoring station.

FUN

Function to be applied to all the monitors at a single time index.

na.rm

Logical specifying whether NA values should be ignored when FUN is applied.

...

additional arguments to be passed on to the apply() function.

Value

A ws_monitor object with meta and data that for the the collapsed single monitor

Note

After FUN is applied, values of +Inf and -Inf are converted to NA. This is a convenience for the common case where FUN=min or FUN=max and some of the timesteps have all missing values. See the R documentation for min for an explanation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(PWFSLSmoke)

N_M <- Northwest_Megafires
# monitor_leaflet(N_M) # to identify Spokane monitorIDs

Spokane <- monitor_subsetBy(N_M, stringr::str_detect(N_M$meta$monitorID,'^53063'))
Spokane_min <- monitor_collapse(Spokane, monitorID='Spokane_min', FUN=min)
Spokane_max <- monitor_collapse(Spokane, monitorID='Spokane_max', FUN=max)

monitor_timeseriesPlot(Spokane, tlim=c(20150619,20150626),
                       style='gnats', shadedNight=TRUE)
monitor_timeseriesPlot(Spokane_max, col='red', type='s', add=TRUE)
monitor_timeseriesPlot(Spokane_min, col='blue', type='s', add=TRUE)
title('Spokane Range of PM2.5 Values, June 2015')

PWFSLSmoke documentation built on Nov. 23, 2021, 5:06 p.m.