This function calculates the daily averaged AQI PM25 categories for the data and colors the data by AQI cateogry when it is added to a plot. The default is to add them as bars.

stat_dailyAQCategory(
  mapping = NULL,
  data = NULL,
  mv4Colors = FALSE,
  timezone = NULL,
  minHours = 18,
  width = 0.8,
  adjustylim = FALSE,
  missingDataBar = TRUE,
  geom = "bar",
  position = "identity",
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  ...
)

Arguments

mapping

Set of aesthetic mappings created by aes(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options: if NULL, the default, the data is inherited from the plot data. A data.frame or other object, will override the plot data. A function will be called witha single argument, the plot data. The return value must be a data.frame, and will be used as the layer data.

mv4Colors

If TRUE, use the colors used in the monitoring v4 site. Otherwise, use the "official" AQI colors.

timezone

timezone for day start and end for averaging. If NULL, uses the timezone used by the x-axis datetime scale. If the x-axis datetime scale has no timezone, it defaults to UTC.

minHours

Minimum number oof valid data hours required to calculate each daily statistic

width

bar width in units of days.

adjustylim

if TRUE, the ylim of the plot will automatically be adjusted for the range of the daily means.

missingDataBar

if TRUE, a transparent gray bar will be plotted where data is missing.

geom

The geometic object to display the data

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

na.rm

remove NA values from data

show.legend

logical indicating whether this layer should be included in legends.

inherit.aes

if FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and the aesthetics and shouldn't inherit behaviour from the default plot specificatino, eg borders().

...

additional arguments passed on to layer(), such as aesthetics.

Examples

if (FALSE) {
library(AirMonitorPlots)

monitor <- airsis_loadLatest()

ggplot_pm25Timeseries(monitor) +
  stat_AQCategory(color = NA, width = 3000) +
  stat_dailyAQCategory(alpha = .5, missingDataBar = FALSE, width = 1, size = 1) +
  facet_wrap(~deviceDeploymentID)

monitor <-
  airnow_loadLatest() %>%
  monitor_filter(id = "a18dacf2eabb6c79_160590004_04")

ggplot_pm25Timeseries(mts_monitor) +
  stat_dailyAQCategory()
}