Skip to contents

Function creates the cloride over time plot with trends.

Usage

trend_plot(
  qw_data,
  plot_title,
  y_label = NA,
  n_years = 10,
  POR_trend = TRUE,
  CharacteristicName = c("Chloride"),
  norm_range = c(230, 860),
  subtitle = "U.S. Geological Survey",
  include_table = TRUE
)

Arguments

qw_data

data frame returned from dataRetrieval::readWQPqw, must include columns ActivityStartDateTime, CharacteristicName, result_va

plot_title

character title for plot

y_label

character label for y axis. If left as NA, the function will attempt to use the "variableInfo" attribute of qw_data. This is attached to dataRetrieval output.

n_years

integer. This is the number of years to calculate the trend on. Default is 10. This can be a vector of years.

POR_trend

a logical indicating whether to include a trend test for the full period of record. Default is TRUE.

CharacteristicName

character CharacteristicName to plot

norm_range

a numerical range to potentially group the data. If NA, no grouping is shown.

subtitle

character. Sub-title for plot, default is "U.S. Geological Survey".

include_table

logical whether or not to include the trend table in the upper left corner.

Examples


# site <- "263819081585801"
# parameterCd <- c("00095","90095","00940","99220")
# site_data <- dataRetrieval::readWQPqw(site, 
#                                        parameterCd)
# Using package example data:
qw_data <- L2701_example_data$QW
plot_title <- paste(attr(qw_data, "siteInfo")[["station_nm"]], ": Chloride")
trend_plot(qw_data, plot_title)
#> Registered S3 methods overwritten by 'ggpp':
#>   method                  from   
#>   heightDetails.titleGrob ggplot2
#>   widthDetails.titleGrob  ggplot2