The System Wide Monitoring Program (SWMP) was implemented by the National Estuarine Research Reserve System (NERRS) in 1995 to provide continuous monitoring data at over 140 continuous monitoring stations in 28 estuaries across the United States. SWMPrExtension (pronounced “swamper extension”) is an R package that provides additional functions to organize and analyze SWMP data and is intended as a companion package for SWMPr (pronounced “swamper”). Currently, there is no citation for SWMPrExtension.
SWMPr is an R package for retrieving, organizing, and analyzing estuary monitoring data from SWMP. SWMPr can be cited as follows:
Beck MW. 2016. SWMPr: An R package for retrieving, organizing, and analyzing environmental data for estuaries. The R Journal. 8(1):219-232. https://journal.r-project.org/archive/2016-1/beck.pdf
This repository is a scientific product and is not official communication of the National Oceanic and Atmospheric Administration, or the United States Department of Commerce. All NOAA GitHub project code is provided on an ?as is? basis and the user assumes responsibility for its use. Any claims against the Department of Commerce or Department of Commerce bureaus stemming from the use of this GitHub project will be governed by all applicable Federal law. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by the Department of Commerce. The Department of Commerce seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by DOC or the United States Government.
Install the package from CRAN:
install.packages('SWMPrExtension')
library(SWMPrExtension)
Install the development (unstable) version from Github:
install.packages('devtools')
library(devtools)
install_github('NOAA-OCM/SWMPrExtension')
library(SWMPrExtension)
Documentation for SWMPrExtension is currently in development.
A quick summary of the SWMPr package can be found here. A detailed manuscript describing full use of the SWMPr package is available from the R Journal. All source materials for the manuscript are available here.
SWMPrExtension adds several functions to existing concepts in SWMPr and introduces a new concept called “Reporting”.
The core analyses available within the SWMPrExtension R package and used to create the reserve level annual report fall into four general categories: boxplots and barplots, range plots, threshold plots, and trend plots. There is also an additional category called “mapping” which contains functions that generate many of maps associated with the reserve-level reports. The analyses, methods, and maps in this section were selected by and approved by a technical advisory committee composed of NERR research coordinators, SWMP technicians and CDMO staff.
annual\_range.swmpr
For a user-specified year, calculate averages, average ranges, and
min/max observed ranges the on a monthly or seasonal basis.
historical\_daily\_range.swmpr
Compare a user-specified year against historical data on a daily basis.
historical\_range.swmpr
Compare a user-specified year against historical data on a
monthly/seasonal basis.
raw\_boxplot.swmpr
Generate a monthly/seasonal boxplots of raw data for a target year.
seasonal\_barplot.swmpr
Generate monthly/seasonal barplot for parameters that are better viewed
in on a cumulative basis (e.g. precipitation).
seasonal\_boxplot.swmpr
Generate monthly/seasonal boxplots for daily average statistics
(min/average/max) across a user-specified time period.Includes the
option to calculate a median value for a target year and include a line
for a water quality threshold.
seasonal\_dot.swmpr
Plot average/min/max seasonal values faceted by season.
sk\_seasonal.swmpr
Seasonal Kendall non-parametric test for monotonic seasonal trends.
threshold\_criteria\_plot.swmpr
Compare raw data against user-specified water quality thresholds
threshold\_identification.swmpr
Identify dates and times that a user-specified water quality threshold
is exceeded. For continuous monitoring data, the user can also specify
the length of time the threshold must be exceeded for the event to be
included (e.g. DO must be \< 2 mg/L for at least 2 hours).
threshold\_percentile\_plot.swmpr
Compare raw data against user-specified percentiles calculated from
historical data. User has the option to calculate percentiles on a
monthly basis.
threshold\_summary.swmpr
Summarize the results from threshold\_identification
in
either a plot or tabular format. Results can be aggregated on a monthly,
seasonal, or annual basis.
national\_sk\_map
Create a base map for NERRS reserves in ggplot with seasonal kendall
results.
res\_custom\_map
Create a stylized reserve-level map of custom station locations for use
with the reserve level reporting template.
res\_custom\_sk\_map
Create a stylized reserve-level map of seasonal kendall results from
custom station locations for use with the reserve level reporting
template.
res\_local\_map
Create a stylized reserve-level map for use with the reserve level
reporting template.
res\_national\_map
Create a base map for NERRS reserves in ggplot.
res\_sk\_map
Create a stylized reserve-level map of seasonal kendall results for use
with the reserve level reporting template.
in the SWMPr
package, retrieve functions help the user load
SWMP data into R.
import\_local\_nut
A modified version of import\_local
from the
SWMPr
package. This version allows the user to specify the
collection method (CollMethd
) argument to separate monthly
nutrient sampling data from monthly 24-hr nutrient sampling data.
The new concept of reporting refers to functions that were specifically developed for use with NERRS reserve-level & national-level reporting scripts that are used to generate the reserve-level and national-level annual reports. They are included as part of this package in case users find them useful for their own purposes.
create\_sk\_flextable\_list
Create a list of flextable
objects to display Seasonal
Kendall results in the NERRS reserve level template.
geographic\_unique\_stations
Creates an alphabetically sorted, vector of geographically unique
stations for mapping. Intended for use with
res\_local\_map
.
get\_reserve
Return the full name of the reserve associated with the data files in
the ‘data’ folder of the reserve level template.
get\_shp\_name
Return the name of the shape file associated with the data files in the
‘data’ folder of the reserve level template.
get\_site\_code
Return the 3 letter reserve code associated with the reserve.
get\_site\_coordinates
Return the station coordinates for stations associated with the data
files in the ‘data’ folder of the reserve level template.
get\_sites
Return the stations associated with the data files in ‘data’ folder of
the reserve level template.
load\_shp\_file
Load and format shapefile for use with res\_local\_map.
create\_sk\_national\_ft\_reserves
Create a flextable
of reserve names for use with the NERRS
national level template.
create\_sk\_national\_ft\_results
Create a flextable
object to display Seasonal Kendall
results for each reserve in the NERRS national level template.
summarise\_handoff\_files
Summarise the seasonal kendall results from reserve level report
hand-off files.
Miscellaneous functions are generally helper functions that are called internally by other analysis functions.
assign\_season
Assign seasons to SWMPr sampling data on a monthly basis or user-defined
basis. Used by multiple analysis functions to group sampling data into
user-defined seasons.
lm\_p\_labs
Generate a dataframe of p-value labels based on p-values from linear
regression. Used internally by seasonal\_dot.swmpr
to add
linear regression results to the plot.
set\_date\_break\_labs
Select reasonable labels for breaks used in
scale\_x\_datetime
. Used internally by several analysis
functions.
set\_date\_breaks
A helper function to select reasonable breaks for
scale\_x\_datetime
. Used internally by several analysis
functions.
sk\_tidy
Tidy results from EnvStats::kendallSeasonalTrendTest
. Used
by sk\_seasonal.swmpr
to tidy seasonal kendall test
results.
std\_param\_check
Determine if a parameter is one of the standard SWMP parameters.
title\_labeler
Generate a plot title based on SWMP station abbreviation. Used
internally by several analysis functions.
y\_count\_labeler
Generate a y-axis label based on SWMP parameter abbreviation. Used
internally by several analysis functions.
y\_labeler
Generate a y-axis label based on SWMP parameter abbreviation and
threshold criteria. Used internally by several analysis functions.
reserve\_locs
Create a dataframe of selected NERRS locations for plotting with
res\_national\_map
.
ft\_col\_names
Convert SWMPr
parameter abbreviations into formats
appropriate for use with NERRS reserve level template
flextable
. Used internally by
create\_sk\_flextable\_list
.
generate\_results\_table
Filters a data.frame
of user-specified results for display
in the NERRS reserve level report. Used internally by
create\_sk\_flextable\_list
.
generate\_station\_table
Filters a data.frame
of user-specified results for display
in the NERRS reserve level report. Used internally by
create\_sk\_flextable\_list
.
remove\_inf\_and\_nan
Removes -Inf
, Inf
, and NaN
from a
matrix. Used internally by several functions to prevent plotting errors.
The following data sets are included within the
SWMPrExtension
package. They are used for examples and for
mapping.
cbm\_spatial
A shapefile of the reserve boundary for Chesapeake Bay-Maryland NERR.
Available from:
.
elk\_spatial
A shapefile of the reserve boundary for Elkhorn Slough NERR. Available
from:
.
elknmnut
Nutrient data (2007-2016) from North Marsh station at Elkhorn Slough
NERR.
elksmwq
Water quality data (2007-2016) from South Marsh station at Elkhorn
Slough NERR.
sampling\_stations
Metadata on NERRS stations provided by the Central Data Management
Office (CDMO) when data is downloaded. Additional formatting applied in
order to make the dataset useful to several SWMPrExtension
functions.
us\_laea
US County boundaries from the US Census Bureau’s MAF/TIGER geographic
database, modified to remove non-ASCII characters. Reprojected using
Lambert Azimuthal Equal Area. Used to create national-level maps.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.