sensor_calendarPlot: Plot time series values in conventional calendar format

Description Usage Arguments Details Value Note References See Also Examples

View source: R/sensor_calendarPlot.R

Description

Function for plotting PM2.5 concentration in a calendar format. This function wraps the openair calendarPlot() function.

Usage

1
2
3
4
5
6
7
8
9
sensor_calendarPlot(
  sensor = NULL,
  colors = NULL,
  breaks = NULL,
  labels = NULL,
  limits = c(0, 100),
  title = NULL,
  data.thresh = 50
)

Arguments

sensor

An 'airsensor' object

colors

Colours to be used for plotting. Options include "aqi", "scaqmd", “default”, “increment”, “heat”, “jet” and RColorBrewer colours — see the openair openColours function for more details. For user defined the user can supply a list of colour names recognised by R (type colours() to see the full list). An example would be cols = c("yellow", "green", "blue")

breaks

If a categorical scale is required then these breaks will be used. For example, breaks = c(0, 50, 100, 1000). In this case “good” corresponds to values berween 0 and 50 and so on. Users should set the maximum value of breaks to exceed the maximum data value to ensure it is within the maximum final range e.g. 100–1000 in this case.

labels

If a categorical scale is required then these labels will be used. Note there is one less label than break. For example, labels = c("good", "bad", "very bad"). breaks must also be supplied if labels are given.

limits

Use this option to manually set the colour scale limits. This is useful in the case when there is a need for two or more plots and a consistent scale is needed on each. Set the limits to cover the maximimum range of the data for all plots of interest. For example, if one plot had data covering 0–60 and another 0–100, then set limits = c(0, 100). Note that data will be ignored if outside the limits range.

title

Optional title. If NULL, a default title will be constructed.

data.thresh

Data capture threshold passed to openair::timeAverage(). For example, data.thresh = 75 means that at least 75 be available in a day for the value to be calculate, else the data is removed.

Details

Data are trimmed to the local-time year or month boundaries as appropriate.

Two special options are provided to specify a set of colors, breaks and labels.

Using colors = "aqi" will use US EPA Air Quality Index colors and breaks defined by breaks <- c(-Inf, 12, 35.5, 55.5, 150.5, 250.5, Inf).

Using colors = "scaqmd" will use a custom set of colors and breaks defined by breaks <- c(-Inf, 12, 35, 55, 75, Inf).

Value

A plot and an object of class "openair".

Note

Daily averages are calculated using LST (Local Standard Time) day boundaries as specified by the US EPA. LST assumes that standard time applies all year round and guarantees that every day has 24 hours – no "spring forward" or "fall back". Because of this, LST daily averages calculated during months where daylight savings time is in effect will differ very slightly from daily averages calculated using local "clock time".

References

EPA AQS Data Dictionary

See Also

https://davidcarslaw.github.io/openair/reference/calendarPlot.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
library(AirSensor)

setArchiveBaseUrl("http://data.mazamascience.com/PurpleAir/v1")

# Monthly plot
sensor <- 
  sensor_loadMonth("scaqmd", 202007) %>%
  sensor_filterMeta(label == "SCSC_33")

sensor_calendarPlot(sensor)

# Annual plot
sensor <- 
  sensor_loadYear("scaqmd", 2020) %>%
  sensor_filterMeta(label == "SCSC_33")

sensor_calendarPlot(sensor)

# SCAQMD colors
sensor_calendarPlot(sensor, "scaqmd")

# Custom continuous color palette from RColorBrewer
sensor_calendarPlot(
  sensor,
  colors = "BuPu",
  title = "2020 Purple Scale",
  limits = range(sensor$data[,-1], na.rm = TRUE) # don't use data$datetime
)


# Custom categorical colors
sensor_calendarPlot(
  sensor,
  colors = c("springgreen2", "gold", "tomato3"),
  breaks = c(-Inf, 25, 50, Inf),
  labels = c("Good", "Fair", "Poor"),
  title = "2020 -- Air Quality Stoplight"
)

AirSensor documentation built on March 13, 2021, 1:07 a.m.