anlzMWRdate {MassWateR} | R Documentation |
Analyze trends by date in results file
Description
Analyze trends by date in results file
Usage
anlzMWRdate(
res = NULL,
param,
acc = NULL,
sit = NULL,
fset = NULL,
thresh,
group = c("site", "locgroup", "all"),
threshlab = NULL,
threshcol = "tan",
site = NULL,
resultatt = NULL,
locgroup = NULL,
dtrng = NULL,
ptsize = 2,
repel = FALSE,
labsize = 3,
expand = c(0.05, 0.1),
confint = FALSE,
palcol = "Set2",
yscl = "auto",
sumfun = yscl,
colleg = FALSE,
ttlsize = 1.2,
runchk = TRUE,
warn = TRUE
)
Arguments
res |
character string of path to the results file or |
param |
character string of the parameter to plot, must conform to entries in the |
acc |
character string of path to the data quality objectives file for accuracy or |
sit |
optional character string of path to the site metadata file or |
fset |
optional list of inputs with elements named |
thresh |
character indicating if relevant freshwater or marine threshold lines are included, one of |
group |
character indicating whether the results are grouped by site (default), combined across location groups, or combined across sites, see details |
threshlab |
optional character string indicating legend label for the threshold, required only if |
threshcol |
character indicating color of threshold lines if available |
site |
character string of sites to include, default all |
resultatt |
character string of result attributes to plot, default all |
locgroup |
character string of location groups to plot from the |
dtrng |
character string of length two for the date ranges as YYYY-MM-DD, default all |
ptsize |
numeric indicating size of the points |
repel |
logical indicating if overlapping site labels are offset, default |
labsize |
numeric indicating font size for the site labels, only if |
expand |
numeric of length two indicating expansion proportions on the x-axis to include labels outside of the plot range if |
confint |
logical indicating if confidence intervals are shown, only applies if data are summarized using |
palcol |
character string indicating the color palette for points and lines from RColorBrewer, see details |
yscl |
character indicating one of |
sumfun |
character indicating one of |
colleg |
logical indicating if a color legend for sites or location groups is included if |
ttlsize |
numeric value indicating font size of the title relative to other text in the plot |
runchk |
logical to run data checks with |
warn |
logical to return warnings to the console (default) |
Details
Results are shown for the selected parameter as continuous line plots over time. Specifying group = "site"
plot a separate line for each site. Specifying group = "locgroup"
will summarize results across sites in the locgroup
argument based on the value passed to sumfun
or yscl
if no value is passed to sumfun
. The site metadata file must be passed to the `sit`
argument to use this option. Specifying group = "all"
will summarize results across sites for each date based on the value passed to sumfun
or yscl
if no value is passed to sumfun
. Summarized results will include confidence intervals if confint = TRUE
and they can be calculated (i.e., more than one point is used in the summary and data are summarized using group
as "locgroup"
or "all"
).
Threshold lines applicable to marine or freshwater environments can be included in the plot by using the thresh
argument. These thresholds are specific to each parameter and can be found in the thresholdMWR
file. Threshold lines are plotted only for those parameters with entries in thresholdMWR
and only if the value in `Result Unit`
matches those in thresholdMWR
. The threshold lines can be suppressed by setting thresh = 'none'
. A user-supplied numeric value can also be used for the thresh
argument to override the default values. An appropriate label must also be supplied to threshlab
if thresh
is numeric.
Any acceptable color palette for from RColorBrewer for the points and lines can be used for palcol
, which is passed to the palette
argument in scale_color_brewer
. These could include any of the qualitative color palettes, e.g., "Set1"
, "Set2"
, etc. The continuous and diverging palettes will also work, but may return color scales for points and lines that are difficult to distinguish. The palcol
argument does not apply if group = "all"
.
The y-axis scaling as arithmetic (linear) or logarithmic can be set with the yscl
argument. If yscl = "auto"
(default), the scaling is determined automatically from the data quality objective file for accuracy, i.e., parameters with "log" in any of the columns are plotted on log10-scale, otherwise arithmetic. Setting yscl = "linear"
or yscl = "log"
will set the axis as linear or log10-scale, respectively, regardless of the information in the data quality objective file for accuracy.
Similarly, the data will be summarized appropriately for group
(only applies if group
is not site) based on the value passed to sumfun
. The default if no value is provided to sumfun
is to use the appropriate summary based on the value provided to yscl
. If yscl = "auto"
(default), then sumfun = "auto"
, and the mean or geometric mean is used for the summary based on information in the data quality objective file for accuracy. Using yscl = "linear"
or yscl = "log"
will default to the mean or geometric mean summary if no value is provided to sumfun
. Any other appropriate value passed to sumfun
will override the value passed to yscl
. Valid summary functions for sumfun
include "auto"
, "mean"
, "geomean"
, "median"
, "min"
, or "max"
).
Any entries in resdat
in the "Result Value"
column as "BDL"
or "AQL"
are replaced with appropriate values in the "Quantitation Limit"
column, if present, otherwise the "MDL"
or "UQL"
columns from the data quality objectives file for accuracy are used. Values as "BDL"
use one half of the appropriate limit.
Value
A ggplot
object that can be further modified.
Examples
# results data path
respth <- system.file('extdata/ExampleResults.xlsx', package = 'MassWateR')
# results data
resdat <- readMWRresults(respth)
# accuracy path
accpth <- system.file('extdata/ExampleDQOAccuracy.xlsx',
package = 'MassWateR')
# accuracy data
accdat <- readMWRacc(accpth)
# site data path
sitpth <- system.file('extdata/ExampleSites.xlsx', package = 'MassWateR')
# site data
sitdat <- readMWRsites(sitpth)
# select sites
anlzMWRdate(res = resdat, param = 'DO', acc = accdat, group = 'site', thresh = 'fresh',
site = c("ABT-026", "ABT-077"))