
Plot time series values in a conventional calendar format
trend_calendar.RdWith a single year of data, trend_calendar() will plot data in a conventional
calendar format, i.e., by month and day of the week. With multiple years of
data, a year-month matrix of panels will instead be plotted. Daily statistics
are calculated using time_average(), which by default will calculate the
daily mean concentration.
Usage
trend_calendar(
data,
pollutant,
statistic = "mean",
data_thresh = 0,
border_colour = "white",
w_shift = 0
)Arguments
- data
A data frame minimally containing
dateand at least one other numeric variable. The date should be in eitherDateformat or classPOSIXct.- pollutant
Mandatory. A pollutant name corresponding to a variable in a data frame should be supplied e.g.
pollutant = "nox".- statistic
Statistic passed to
time_average().- data_thresh
Data capture threshold passed to
time_average(). For example,data_thresh = 75means that at least 75\ be available in a day for the value to be calculate, else the data is removed.- border_colour
The colour to use for the border of each tile. Defaults to "white".
NAremoves the border.- w_shift
Controls the order of the days of the week. By default the plot shows Saturday first (
w_shift = 0). To change this so that it starts on a Monday for example, setw_shift = 2, and so on.
Details
trend_calendar() has two accompanying annotation functions.
annotate_calendar_text() can write either the day of the month or the
average pollutant concentration on the calendar. annotate_calendar_wd()
will draw wind speed and direction arrows onto the calendar, assuming columns
labelled "ws" and "wd" were present in the original data.
Note that is is possible to pre-calculate concentrations in some way before
passing the data to trend_calendar(). For example openair::rollingMean()
could be used to calculate rolling 8-hour mean concentrations. The data can
then be passed to trend_calendar() and statistic = "max" chosen, which
will plot maximum daily 8-hour mean concentrations.
See also
annotate_calendar_wd() and annotate_calendar_text() for
annotating calendar plots.
Other time series and trend functions:
trend_level(),
trend_prop(),
trend_variation()
Examples
if (FALSE) {
marylebone %>%
selectByDate(year = 2019) %>%
trend_calendar("nox") +
annotate_calendar_text(colour = "white", size = 5, type = "date") +
annotate_calendar_wd(colour = "black")
}