monitor_ggDailyHourlyBarplot: Create a Daily-Hourly plot for many monitors

View source: R/monitor_ggDailyHourlyBarplot.R

monitor_ggDailyHourlyBarplotR Documentation

Create a Daily-Hourly plot for many monitors

Description

Create a time series barplot showing PM2.5 data for the given monitors. The overall plot is faceted by monitor, and each facet has two sets of columns: one for daily levels, and one for hourly levels.

The full range of data in monitor will be used unless both startdate and enddate are specified.

The timezone specified or, if timezone = NULL, that of the first monitor encountered will be used for all time axes.

Usage

monitor_ggDailyHourlyBarplot(
  monitor,
  startdate = NULL,
  enddate = NULL,
  id = NULL,
  columns = 1,
  title = NULL,
  timezone = NULL,
  xLabel = NULL,
  yLabel = NULL,
  includeLink = TRUE,
  hourlyDataType = c("nowcast", "raw", "none"),
  palette = "epa_aqi",
  includeLegendAdvice = FALSE
)

Arguments

monitor

A mts_monitor object.

startdate

Desired start date (integer or character in ymd format or POSIXct).

enddate

Desired end date (integer or character in ymd format or POSIXct).

id

Optional vector of deviceDeploymentIDs used to filter the data.

columns

Number of columns the faceted plot should have (default 1).

title

The title of the plot. Defaults to specifying the types of data present in the plot.

timezone

Olson timezone name for x-axis scale and date parsing. If NULL the timezone of the specified monitor will be used.

xLabel

The x-axis label of the plot. Defaults to years present in data.

yLabel

The y-axis label of the plot. Defaults to PM2.5.

includeLink

Option to include a link to an AQI help page at the bottom of the plot (default 'TRUE').

hourlyDataType

The type of hourly data to include in the plot. The options include "nowcast" (hourly nowcast values), "raw" (raw hourly values), or "none" (no hourly data at all) (default "nowcast").

palette

The ordered color palette used to represent each AQI category. Currently defaults to (and only accepts) "epa_aqi".

includeLegendAdvice

Option to include a third column in the legend for AQI level advice. Currently in testing (default 'False').

Value

A **ggplot** plot of the given monitors and data.

Examples

## Not run: 
library(AirMonitorPlots)

SF_IDs <- c(
  "ccdef3f0f6591e77_060010009",
  "06c3f2a66f8b708e_060010012",
  "7157b3dbac7c2043_060010011",
  "060750fa7ae26987a72cc4_060750005005_01"
)
SF_daily <- loadDaily() %>% monitor_select(id = SF_IDs)
SF_latest <- loadLatest() %>% monitor_select(id = SF_IDs)
SF_full <- monitor_join(SF_daily, SF_latest)
today <- lubridate::floor_date(lubridate::now('America/Los_Angeles'), unit='day')
now <- lubridate::floor_date(lubridate::now('America/Los_Angeles'), unit='hour')
starttime <- today - lubridate::ddays(4)
SF_4day <- monitor_filterDatetime(SF_full, starttime, now))

# Create plot using pre subset data
monitor_ggDailyHourlyBarplot(SF_4day, id = SF_IDs)

# Create plot using data subset by function
monitor_ggDailyHourlyBarplot(SF_full, starttime, now, SF_IDs)

## End(Not run)

MazamaScience/AirMonitorPlots documentation built on May 8, 2024, 6:16 a.m.