Learn R Programming

SWMPrExtension (version 0.3.12)

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), by_month = TRUE, 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.

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.

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), target_yr = 2014, by_month = TRUE)


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)

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

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

Run the code above in your browser using DataLab