Learn R Programming

AirMonitor (version 0.4.2)

aqiColors: Generate AQI colors

Description

This function uses the leaflet::colorBin() function to return a vector or matrix of colors derived from data values.

Usage

aqiColors(
  x,
  pollutant = c("PM2.5", "AQI", "CO", "NO", "OZONE", "PM10", "SO2"),
  palette = c("EPA", "subdued", "deuteranopia"),
  na.color = NA,
  NAAQS = c("PM2.5_2024", "PM2.5")
)

Value

A vector or matrix of AQI colors to be used in maps and plots.

Arguments

x

Vector or matrix of PM2.5 values or an mts_monitor object.

pollutant

EPA AQS criteria pollutant.

palette

Named color palette to use for AQI categories.

na.color

Color assigned to missing values.

NAAQS

Version of NAAQS levels to use. See Note.

See Also

aqiCategories

Examples

Run this code
library(AirMonitor)

# Fancy plot based on pm2.5 values
pm2.5 <- Carmel_Valley$data[,2]
Carmel_Valley %>%
  monitor_timeseriesPlot(
    shadedNight = TRUE,
    pch = 16,
    cex = pmax(pm2.5 / 100, 0.5),
    col = aqiColors(pm2.5),
    opacity = 0.8
  )

Run the code above in your browser using DataLab