Learn R Programming

openair (version 0.3-13)

timeVariation: Diurnal and day of week variation

Description

Plots the diurnal and day of the week variation for different variables, typically pollutant concentrations. Three separate plots are produced.

Usage

timeVariation(mydata,
pollutant = "nox",
local.time = FALSE,
normalise = FALSE,
ylab = pollutant,
xlab = NULL,
name.pol = pollutant,
type = "default",
ci = TRUE,
cols = "hue",
main = "",
key = NULL,
key.columns = 1,
auto.text = TRUE,
alpha = 0.4,...)

Arguments

mydata
A data frame of hourly (or higher temporal resolution data). Must include a date field and at least one variable to plot.
pollutant
Name of variable to plot. Two or more pollutants can be plotted, in which case a form like pollutant = c("nox", "co") should be used.
local.time
Should the results be calculated in local time? The default is FALSE. Emissions activity tends to occur at local time e.g. rush hour is at 8 am every day. When the clocks go forward in spring, the emissions are effectively rele
normalise
Should variables be normalised? The default is FALSE. If TRUE then the variable(s) are divided by their mean values. This helps to compare the shape of the diurnal trends for variables on very different scales.
ylab
Name of y-axis variable. By default will use the name of pollutant.
xlab
x-axis label.
name.pol
Names to be given to the pollutant(s). This is useful if you want to give a fuller description of the variables, maybe also including subscripts etc.
type
Can either be default or site. If site is chosen then the data frame must contain a field named site. The openair manual shows how the site field can be used in a
ci
Should confidence intervals be shown? The default is TRUE. Setting this to FALSE can be useful if multiple pollutants are chosen where over-lapping confidence intervals can over complicate plots.
cols
Colours to be used for plotting. Options include "default", "increment", "heat", "spectral", "hue" (default) and user defined (see manual for more details).
main
The plot title; default is no title.
key
By default timeVariation produces four plots on one page. While it is useful to see these plots together, it is sometimes necessary just to use one for a report. If key is TRUE, a key is added to all plots a
key.columns
Number of columns to be used in the key. With many pollutants a single column can make to key too wide. The user can thus choose to use several columns by setting columns to be less thna the number of pollutants.
auto.text
Either TRUE (default) or FALSE. If TRUE titles and axis labels will automatically try and format pollutant names and units properly e.g. by subscripting the `2' in NO2.
alpha
The alpha transparency used for plotting confidence intervals. 0 is fully transparent and 1 is opaque. The default is 0.4
...
Other graphical parameters.

Details

The variation of pollutant concentrations by hour of the day and day of the week can reveal many interesting features that relate to source types. For traffic sources, there are often important differences in the way vehicles vary by vehicles type e.g. less heavy vehicles at weekends. The timeVariation function makes it easy to see how concentrations (and many other variable types) vary by hour of the day and day of the week. The plots also show the 95% confidence intervals in the mean, which is particularly useful for comparing two different pollutants whose concentrations have been normalised. Note also that the timeVariation function works well on a subset of data and in conjunction with other plots. For example, a polarPlot may highlight an interesting feature for a particular wind speed/direction range. By filtering for those conditions timeVariation can help determine whether the temporal variation of that feature differs from other features --- and help with source identification. In addition, timeVariation will work well with other variables if available. Examples include meteorological and traffic flow data. The option type = "site" provides great flexibility. For example, looking a variations across multiple sites, by different time periods. The latter is particularly useful to see if diurnal variations etc. vary over time. See the full documentation for details of use. Results are returned as a list - both the numerical and individual plots. See examples below for details.

See Also

polarPlot, linearRelation

Examples

Run this code
# basic use
timeVariation(mydata, pollutant = "nox")

# for a subset of conditions
timeVariation(subset(mydata, ws > 3 & wd > 100 & wd < 270),
pollutant = "pm10", ylab = "pm10 (ug/m3)")

# multiple pollutants with concentrations normalised
timeVariation(mydata, pollutant = c("nox", "co"), normalise = TRUE)

# show BST/GMT variation (see ?cutData for more details)
# the NOx plot shows the profiles are very similar when expressed in
# local time, showing that the profile is dominated by a local source
# that varies by local time and not by GMT i.e. road vehicle emissions

timeVariation(mydata, pollutant = "nox", type = "gmtbst")

# By contrast, a variable such as wind speed shows a clear shift when
#  expressed in local time. These two plots can help show whether the
#  variation is dominated by man-made influences or natural processes

timeVariation(mydata, pollutant = "ws", type = "gmtbst")

## sub plots can be extracted, in which case set key = TRUE
## plots are retruned in a list e.g. to get the diurnal plot of NO2:
results <- timeVariation(mydata, pollutant = "no2", key = TRUE)
results[[6]] ## plots diurnal plot on its own

## results[[5]] is the weekday and hour plot
## results[[7]] is the weekday plot
## results[[8]] is the monthly plot

## numerical results (mean, lower/upper uncertainties)
## results[[1]] are the weekday and hour results
## results[[2]] are the diurnal results
## results[[3]] are the weekday results
## results[[4]] are the monthly results

Run the code above in your browser using DataLab