Creates a dataframe with data from a ws_monitor object, essentially flattening the object. This is especially useful when monitoring data will be shared with non-R users working with spreadsheets. The returned dataframe will contain data from the monitor specified with monitorID.

The number of data columns in the returned dataframe can include all metadata as well as additional calculated values.

By default, the following, core columns are included in the dataframe:

  • utcTime UTC datetime

  • localTime local datetime

  • pm25 PM2.5 values in ug/m3

Any column from ws_monitor$meta may be included in the vector of metaColumns.

The following additional columns of data may be included by adding one of the following to the vector of extraColumns{}

monitor_asDataframe(
  ws_monitor,
  monitorID = NULL,
  extraColumns = NULL,
  metaColumns = NULL,
  tlim = NULL
)

Arguments

ws_monitor

ws_monitor object

monitorID

monitor ID of interest (not needed if ws_monitor contains only one monitor)

extraColumns

optional vector of additional data columns to generate

metaColumns

optional vector of column names from ws_monitor$meta

tlim

optional vector with start and end times (integer or character representing YYYYMMDD[HH] or POSIXct)

Value

A dataframe version of a ws_monitor object.

Note

The tlim argument is interpreted as localtime, not UTC.

See also

Examples

# \donttest{ library(PWFSLSmoke) wa <- monitor_subset(Northwest_Megafires, stateCodes='WA') Omak_df <- monitor_asDataframe(wa, monitorID='530470013_01', extraColumns=c('nowcast','dailyAvg'), metaColumns=c('aqsID','siteName','timezone'), tlim=c(20150801,20150901)) dplyr::glimpse(Omak_df)
#> Rows: 745 #> Columns: 8 #> $ utcTime <chr> "2015-08-01 07:00:00 +0000", "2015-08-01 08:00:00 +0000", "2… #> $ localTime <chr> "2015-08-01 00:00:00 -0700", "2015-08-01 01:00:00 -0700", "2… #> $ pm25 <dbl> 16.9, 12.7, 11.8, 9.9, 9.3, 9.9, 11.2, 10.3, 11.1, 6.4, 5.1,… #> $ nowcast <dbl> 19.3, 16.0, 13.9, 11.9, 10.6, 10.2, 10.7, 10.5, 10.8, 8.6, 6… #> $ dailyAvg <dbl> 23.4, 23.4, 23.4, 23.4, 23.4, 23.4, 23.4, 23.4, 23.4, 23.4, … #> $ aqsID <chr> "530470013", "530470013", "530470013", "530470013", "5304700… #> $ siteName <chr> "Omak-Colville Tribe", "Omak-Colville Tribe", "Omak-Colville… #> $ timezone <chr> "America/Los_Angeles", "America/Los_Angeles", "America/Los_A…
# }