threshold_criteria_plot {SWMPrExtension}R Documentation

Water Quality Threshold Plot For Parameters With Criteria

Description

Observed data compared against user-defined water quality thresholds

Usage

threshold_criteria_plot(swmpr_in, ...)

## S3 method for class 'swmpr'
threshold_criteria_plot(
  swmpr_in,
  param = NULL,
  rng = NULL,
  thresholds = NULL,
  threshold_labs = c("Good", "Fair", "Poor"),
  threshold_cols = c("#ABD9E9", "#FFFFCC", "#FEC596"),
  crit_threshold = NULL,
  log_trans = FALSE,
  monthly_smooth = FALSE,
  plot_title = FALSE,
  ...
)

Arguments

swmpr_in

input swmpr object

...

additional arguments passed to other methods. See y_labeler.

param

chr string of the variable to plot

rng

num, years to include in the plot. This variable can either be one year (e.g., rng = 2012), or two years (e.g. rng = c(2012, 2016)) , If range is not specified then the entire data set will be used.

thresholds

numeric vector, numeric criteria that will be plotted in the background

threshold_labs

chr vector of labels for categories created by thresholds.

threshold_cols

chr vector of color values for categories created by thresholds.

crit_threshold

num, value at which the critical threshold line should be plotted. Typically the same value used to establish the 'Poor' threshold.

log_trans

logical, should y-axis be log? Defaults to FALSE

monthly_smooth

logical, calculate a monthly average? Defaults to FALSE

plot_title

logical, should the station name be included as the plot title? Defaults to FALSE

Details

This function visualizes exceedances of numeric criteria which are specified using thresholds. Suggested numeric criteria for several parameters (dissolved oxygen, dissolved inorganic phosphorus, dissolved inorganic nitrogen, and chlorophyll-a) can be found in the USEPA National Coastal Condition Report (2012).

If the parameter of interest does not have numeric criteria, then threshold_percentile_plot is recommended.

Value

Returns a ggplot object

Author(s)

Julie Padilla

References

United States Environmental Protection Agency (USEPA). 2012. "National Coastal Condition Report IV." https://www.epa.gov/national-aquatic-resource-surveys/national-coastal-condition-report-iv-2012

See Also

ggplot,y_labeler

Examples

data(apacpwq)
dat_wq <- apacpwq

dat_wq <- qaqc(dat_wq, qaqc_keep = c(0, 3, 5))

## Due to the volume of instantaneous data, these plots are a bit slow
x <-
  threshold_criteria_plot(dat_wq, param = 'do_mgl'
                 , rng = 2012
                 , thresholds = c(2, 5)
                 , threshold_labs = c('Poor', 'Fair', 'Good')
                 , monthly_smooth = TRUE
                 , threshold_cols = c('#FEC596', '#FFFFCC', '#ABD9E9'))


y <-
  threshold_criteria_plot(dat_wq, param = 'do_mgl'
                 , thresholds = c(2, 5)
                 , threshold_labs = c('Poor', 'Fair', 'Good')
                 , threshold_cols = c('#FEC596', '#FFFFCC', '#ABD9E9'))

z <-
  threshold_criteria_plot(dat_wq, param = 'do_mgl'
                 , rng = 2012
                 , thresholds = c(2, 5)
                 , threshold_labs = c('Poor', 'Fair', 'Good')
                 , threshold_cols = c('#FEC596', '#FFFFCC', '#ABD9E9')
                 , monthly_smooth = TRUE)

## A few examples with only two thresholds
x1 <-
  threshold_criteria_plot(dat_wq, param = 'do_mgl'
                 , rng = 2012
                 , thresholds = c(2, 2)

                  # A dummy blank ('') value must be added as a threshold label
                 , threshold_labs = c('Poor', '', 'Good')
                 , threshold_cols = c('#FEC596', '#FFFFCC', '#ABD9E9')
                 , monthly_smooth = TRUE)

y1 <-
  threshold_criteria_plot(dat_wq, param = 'do_mgl'
                 , rng = 2012
                 , thresholds = c(5, 5)

                 # A dummy blank ('') value must be added as a threshold label
                 , threshold_labs = c('Poor', '', 'Good')
                 , threshold_cols = c('#FEC596', '#FEC596', '#ABD9E9')
                 , monthly_smooth = TRUE)

z1 <-
  threshold_criteria_plot(dat_wq, param = 'do_mgl'
                 , rng = 2012
                 , thresholds = c(2, 5)
                 , threshold_labs = c('Poor', 'Good', 'Poor')
                 , threshold_cols = c('#FEC596', '#ABD9E9', '#FEC596')
                 , monthly_smooth = TRUE)


data(apacpnut)
dat_nut <- apacpnut

dat_nut <- qaqc(dat_nut, qaqc_keep = c(0, 3, 5))
dat_nut <- rem_reps(dat_nut)

x2 <-
  threshold_criteria_plot(dat_nut, param = 'chla_n'
                 , thresholds = c(2, 5)
                 , threshold_labs = c('Good', 'Fair', 'Poor'))


y2 <-
  threshold_criteria_plot(dat_nut, param = 'chla_n'
                 , rng = 2012
                 , thresholds = c(2, 5)
                 , threshold_labs = c('Good', 'Fair', 'Poor'))

## Nutrient plots are not capable of accidentally displaying any kind of smooth
z2 <-
  threshold_criteria_plot(dat_nut, param = 'chla_n'
                 , rng = 2012
                 , thresholds = c(2, 5)
                 , threshold_labs = c('Good', 'Fair', 'Poor')
                 , monthly_smooth = TRUE)


[Package SWMPrExtension version 2.2.5.1 Index]