View source: R/variationPlot.R
| variationPlot | R Documentation |
The variationPlot() function is designed to explore how the distribution of
a pollutant (or other variable) changes by another variable (x). For
example, it can be used to explore how the distribution of nox varies by
season or by weekday. This plot can be extensively conditioned using the
type and group arguments, both of which are passed to cutData(). An
appropriate plot type will be chosen based on the type of x - e.g., ordered
variables will be joined by a line.
variationPlot(
mydata,
pollutant = "nox",
x = "hour",
statistic = "mean",
type = "default",
group = "default",
normalise = FALSE,
difference = FALSE,
conf.int = NULL,
B = 100,
local.tz = NULL,
ci = TRUE,
cols = "hue",
alpha = 0.4,
strip.position = "top",
key.position = "top",
key.columns = NULL,
name.pol = NULL,
auto.text = TRUE,
plot = TRUE,
...
)
mydata |
A data frame of time series. Must include a |
pollutant |
Name of variable to plot. Two or more pollutants can be
plotted, in which case a form like |
x |
A character value to be passed to |
statistic |
Can be |
type |
Character string(s) defining how data should be split/conditioned
before plotting.
Most |
group |
This sets the grouping variable to be used. For example, if a
data frame had a column |
normalise |
Should variables be normalised? The default is |
difference |
If two pollutants are chosen then setting |
conf.int |
The confidence intervals to be plotted. If |
B |
Number of bootstrap replicates to use. Can be useful to reduce this value when there are a large number of observations available to increase the speed of the calculations without affecting the 95% confidence interval calculations by much. |
local.tz |
Used for identifying whether a date has daylight savings time
(DST) applied or not. Examples include |
ci |
Should confidence intervals be shown? The default is |
cols |
Colours to use for plotting. Can be a pre-set palette (e.g.,
|
alpha |
The alpha transparency used for plotting confidence intervals.
|
strip.position |
Location where the facet 'strips' are located when
using |
key.position |
Location where the legend is to be placed. Allowed
arguments include |
key.columns |
Number of columns to be used in a categorical legend. With
many categories a single column can make to key too wide. The user can thus
choose to use several columns by setting |
name.pol |
This option can be used to give alternative names for the
variables plotted. Instead of taking the column headings as names, the user
can supply replacements. For example, if a column had the name "nox" and
the user wanted a different description, then setting |
auto.text |
Either |
plot |
When |
... |
Addition options are passed on to
|
When statistic = "mean", the plot shows the 95% confidence intervals in the
mean. The 95% confidence intervals are calculated through bootstrap
simulations, which will provide more robust estimates of the confidence
intervals (particularly when there are relatively few data).
Users can supply their own ylim, e.g. ylim = c(0, 200).
The difference option calculates the difference in means between two
pollutants, along with bootstrap estimates of the 95\
in the difference. This works in two ways: either two pollutants are supplied
in separate columns (e.g. pollutant = c("no2", "o3")), or there are two
unique values of group. The difference is calculated as the second
pollutant minus the first and is labelled accordingly. This feature is
particularly useful for model evaluation and identifying where models diverge
from observations across time scales.
Depending on the choice of statistic, a subheading is added. Users can
control the text in the subheading through the use of sub e.g. sub = ""
will remove any subheading.
an openair object.
Jack Davison
David Carslaw
timeVariation(), which conveniently assembles many time-related
variation plots into a single plot
# example using the 'mydata' dataset
variationPlot(
mydata,
pollutant = c("nox", "o3"),
x = "hour",
type = "season",
normalise = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.