Get the lesson R script: wq.R
Get the lesson data: download zip
This module will provide you with background into the structure of the peptools R package and how to use functions in this package to read, analyze, and plot water quality indicators for the Peconic Estuary Program. You should be able to answer these questions at the end of this session:
The peptools package was developed as a set of functions to read, analyze, and plot water quality data relevant for the PEP. the package source code lives on GitHub. A website that includes function references and full documentation is also provided. The following shows all functions provided in peptools, organized by prefix.
read_pepdo()
: Import dissolved oxygen data
read_pepwq()
: Load local water quality file
read_pepent()
: Load Enterococcus beach data file
anlz_attainpep()
: Get attainment categories
anlz_dodlypep()
: Analyze daily DO values relative to threshold
anlz_domopep()
: Analyze monthly DO values relative to threshold
anlz_entpep()
: Count beach exceedances for enterococcus
anlz_medpep()
: Estimate annual medians
show_boxpep()
: Plot monthly chlorophyll or secchi depth values for a bay segment
show_entmatrix()
: Create a colorized table for beach closure reporting
show_matrixpep()
: Create a colorized table for indicator reporting
show_reactablepep()
: Create a reactable table for reporting matrices, used internally only
show_sitemappep()
: Map water quality data for a selected year
show_thrpep()
: Plot annual water quality values and thresholds for a bay segment
show_plotlypep()
: Plot chlorophyll and secchi data together with matrix outcomes
show_wqmatrixpep()
: Create a colorized table for chlorophyll or secchi exceedances
show_segmatrixpep()
: Create a colorized table for water quality outcomes and exceedances by segment
Before we use the package, we’ll load it into our current R session as follows. We’ll also load the mapview package. You should have already installed these packages in the previous lesson.
library(peptools)
library(mapview)
The package includes a pepstations
data object that includes metadata for each station, including lat/lon and bay segment.
pepstations
## # A tibble: 46 x 5
## BayStation StationName bay_segment Longitude Latitude
## * <chr> <chr> <fct> <dbl> <dbl>
## 1 60280 Peconic River Western -72.7 40.9
## 2 60275 Peconic River Western -72.7 40.9
## 3 60270 Peconic River Western -72.6 40.9
## 4 60265 Peconic River Western -72.6 40.9
## 5 60266 Peconic River Western -72.6 40.9
## 6 60260 Peconic River Western -72.6 40.9
## 7 60250 Sawmill Creek Western -72.6 40.9
## 8 60240 Peconic River Mouth Western -72.6 40.9
## 9 60230 Terrys Creek Western -72.6 40.9
## 10 60210 Reeves Bay Western -72.6 40.9
## # ... with 36 more rows
The pepseg
data object also included with the package shows the polygons for the bay segments. These data are included as a geographic data object, so they can be viewed with the mapview package.
mapview(pepseg)