| trendLevel | R Documentation |
The trendLevel() function provides a way of rapidly showing a large amount
of data in a condensed form. In one plot, the variation in the concentration
of one pollutant can to shown as a function of between two and four
categorical properties. The default arguments plot hour of day on the x-axis
and month of year on the y-axis. However, x, y and type and summarising
statistics can all be modified to provide a range of other similar plots, all
being passed to cutData() for discretisation. The average wind speed and
direction in each bin can also be plotted using the windflow argument.
trendLevel(
mydata,
pollutant = "nox",
x = "month",
y = "hour",
type = "default",
rotate.axis = c(90, 0),
n.levels = c(10, 10, 4),
windflow = NULL,
limits = NULL,
min.bin = 1,
cols = "default",
auto.text = TRUE,
key.title = paste("use.stat.name", pollutant, sep = " "),
key.position = "right",
strip.position = "top",
labels = NULL,
breaks = NULL,
statistic = c("mean", "max", "min", "median", "frequency", "sum", "sd", "percentile"),
percentile = 95,
stat.args = NULL,
stat.safe.mode = TRUE,
drop.unused.types = TRUE,
col.na = "white",
plot = TRUE,
key = NULL,
...
)
mydata |
The openair data frame to use to generate the |
pollutant |
The name of the data series in |
x, y, type |
The name of the data series to use as the |
rotate.axis |
The rotation to be applied to |
n.levels |
The number of levels to split |
windflow |
If |
limits |
The colour scale range to use when generating the
|
min.bin |
The minimum number of records required in a bin to show a
value. Bins with fewer than |
cols |
Colours to use for plotting. Can be a pre-set palette (e.g.,
|
auto.text |
Either |
key.title |
Used to set the title of the legend. The legend title is
passed to |
key.position |
Location where the legend is to be placed. Allowed
arguments include |
strip.position |
Location where the facet 'strips' are located when
using |
breaks, labels |
If a categorical colour scale is required then |
statistic |
The statistic to apply when aggregating the data; default is
the mean. Can be one of |
percentile |
The percentile level used when |
stat.args |
Additional options to be used with |
stat.safe.mode |
An addition protection applied when using functions
directly with |
drop.unused.types |
Hide unused/empty |
col.na |
Colour to be used to show missing data. |
plot |
When |
key |
Deprecated; please use |
... |
Addition options are passed on to
|
trendLevel() allows the use of third party summarising functions via the
statistic option. Any additional function arguments not included within a
function called using statistic should be supplied as a list of named
parameters and sent using stat.args. For example, the encoded option
statistic = "mean" is equivalent to statistic = mean, stat.args = list(na.rm = TRUE) or the R command mean(x, na.rm = TRUE). Many R
functions and user's own code could be applied in a similar fashion, subject
to the following restrictions: the first argument sent to the function must
be the data series to be analysed; the name 'x' cannot be used for any of the
extra options supplied in stat.args; and the function should return the
required answer as a numeric or NA. Note: If the supplied function returns
more than one answer, currently only the first of these is retained and used
by trendLevel(). All other returned information will be ignored without
warning. If the function terminates with an error when it is sent an empty
data series, the option stat.safe.mode should not be set to FALSE or
trendLevel() may fail. Note: The stat.safe.mode = TRUE option returns an
NA without warning for empty data series.
an openair object.
Karl Ropkins
David Carslaw
Jack Davison
# basic use
# default statistic = "mean"
trendLevel(mydata, pollutant = "nox")
# applying same as 'own' statistic
my.mean <- function(x) mean(x, na.rm = TRUE)
trendLevel(mydata, pollutant = "nox", statistic = my.mean)
# alternative for 'third party' statistic
# trendLevel(mydata, pollutant = "nox", statistic = mean,
# stat.args = list(na.rm = TRUE))
## Not run:
# example with categorical scale
trendLevel(mydata,
pollutant = "no2",
border = "white", statistic = "max",
breaks = c(0, 50, 100, 500),
labels = c("low", "medium", "high"),
cols = c("forestgreen", "yellow", "red")
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.