plot_al: Plot the action levels of chlorine results

View source: R/plot-al.R

plot_alR Documentation

Plot the action levels of chlorine results

Description

Generate plots showing whether an action level is exceeded

Usage

plot_al(
  data,
  date_col,
  value_col,
  ...,
  method = c("FL", "P"),
  percentiles = c(0.8, 0.5, 0.1),
  rolling_window = 8,
  smooth_deriv = FALSE,
  deriv_window = NULL,
  max_chlorine = 1.5,
  date_breaks = "6 months",
  date_labels = "%b %d, %Y",
  ylab = "",
  plot_title = "",
  plot_subtitle = "",
  legend_title = "",
  action_levels = NULL,
  theme = NULL,
  ncol = NULL,
  nrow = NULL
)

Arguments

data

a data frame or tibble that has chlorine residual data

date_col

the unquoted column name of the date/datetime column

value_col

the unqouted column name of the chlorine residual column

...

unqouted column names of all grouping columns

method

either "FL" or "P" to distinguish how you want the action levels to be calculated

percentiles

the percentiles that will be used to calculate the action levels of either the falling limb (if method = "FL") or the overall distribution (if method = "P")

rolling_window

how many weeks of data should be included in the rolling average window function when calculating the first and second derivative of the chlorine time series. Defaults to 8.

max_chlorine

maximum chlorine residual value that can be included in falling limb. For example, if you are not concerned with sites when chlorine is greater than 1.5 (default) than no value greater than this threshold will be classified as either "Falling Limb" or "Nitrification Ongoing"

date_breaks

a character string to be passed to either ggplot2::scale_x_date or ggplot2::scale_x_datetime to specify the spacing of date breaks (e.g. "1 month" or "3 weeks")

date_labels

a character string specifying the desired output format of dates on x axis. See strptime for options

ylab

a character string specifying the y axis label for the main plot

plot_title

a character string specifying the title of the plot

plot_subtitle

a character string specifying the subtitle of the plot

legend_title

a character string specifying the legend title

action_levels

a numeric vector specifying action levels. If this is NULL (default) than the action levels will be specified via the method provided in the method argument. If this argument is given, then the vector will be sorted with the lowest number by default being the highest action level and the highest number given being the lowest action level. The number of action levels in the resulting data will be equal to the number of action levels given

ncol, nrow

If grouping variable is specified, these arguments set the number of columns and rows, respectively of the resultant faceted plot


tbradley1013/dwqr documentation built on Feb. 11, 2024, 10:03 a.m.