Learn R Programming

SWMPrExtension (version 1.1.6)

threshold_percentile_plot: Threshold Percentile Plot

Description

Observed data compared against user-defined percentiles

Usage

threshold_percentile_plot(swmpr_in, ...)

# S3 method for swmpr threshold_percentile_plot( swmpr_in, param = NULL, hist_rng = NULL, target_yr = NULL, percentiles = c(0.05, 0.95), free_y = FALSE, by_month = FALSE, log_trans = FALSE, converted = FALSE, plot_title = FALSE, ... )

Arguments

swmpr_in

input swmpr object

...

additional arguments passed to other methods (not used for this function).

param

chr, variable to plot

hist_rng

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

target_yr

num, year of interest for plotting. If not specified, the entire data set will be plotted.

percentiles

num, percentiles to calculate (maximum: 2). Defaults to 5th and 95th percentiles.

free_y

logical, should the y-axis be free? Defaults to FALSE. If FALSE, defaults to zero, unless negative values are present. If TRUE, y-axis limits are selected by ggplot

by_month

logical. should percentiles be calculated on a monthly basis? Defaults to FALSE

log_trans

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

converted

logical, were the units converted from the original units used by CDMO? Defaults to FALSE. See y_labeler for details.

plot_title

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

Value

Returns a ggplot object

Details

This function provides an alternative to threshold_criteria_plot. For parameters that may not have numeric threshold criteria, a percentile threshold can be used instead. For a one-tailed analysis, the 90-th percentile is recommended. For a two-tailed analysis, the 5-th and 95-th percentiles are recommended.

Using by_month, the user can specify whether the percentiles should be calculated on a monthly basis or by using the entire data set.

Recommended thresholds for chlorophyll-a, dissolved inorganic nitrogen, dissolved inorganic phosphorus, and dissolved oxygen can be found in the National Coastal Condition Assessment 2010 (USEPA 2016)

References

United States Environmental Protection Agency (USEPA). 2015. "National Coastal Condition Assessment 2010". EPA 841-R-15-006. https://cfpub.epa.gov/si/si_public_record_Report.cfm?Lab=OWOW&dirEntryId=327030

See Also

ggplot

Examples

Run this code
# NOT RUN {
dat_wq <- qaqc(elksmwq, qaqc_keep = c(0, 3, 5))
dat_wq <- subset(dat_wq, subset = '2007-01-01 0:00', operator = '>=')

x <-
  threshold_percentile_plot(dat_wq, param = 'do_mgl'
                           , hist_rng = c(2007, 2014), by_month = FALSE)

# }
# NOT RUN {
y <-
  threshold_percentile_plot(dat_wq, param = 'do_mgl', percentiles = c(0.95)
                           , hist_rng = c(2007, 2014), target_yr = 2014
                           , by_month = FALSE)

x2 <-
  threshold_percentile_plot(dat_wq, param = 'do_mgl'
                           , hist_rng = c(2007, 2014), by_month = TRUE)

y2 <-
  threshold_percentile_plot(dat_wq, param = 'do_mgl'
                           , hist_rng = c(2007, 2014), by_month = TRUE
                           , target_yr = 2014)


dat_nut <- qaqc(elknmnut, qaqc_keep = c(0, 3, 5))
dat_nut <- subset(dat_nut, subset = '2007-01-01 0:00', operator = '>=')
dat_nut <- rem_reps(dat_nut)

x3 <-
  threshold_percentile_plot(dat_nut, param = 'chla_n'
                           , hist_rng = c(2007, 2014), by_month = FALSE)

y3 <-
  threshold_percentile_plot(dat_nut, param = 'chla_n'
                           , hist_rng = c(2007, 2014), by_month = FALSE
                           , target_yr = 2016)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab