CRAN_Status_BadgeDownloads from the RStudio CRAN mirror

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

Overview

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

NOAA Open Source Disclaimer

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.

Installing the package

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)

Using the package

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".

Analyze

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.

Core Analyses

annual_range.swmprFor a user-specified year, calculate averages, average ranges, and min/max observed ranges the on a monthly or seasonal basis.
historical_daily_range.swmprCompare a user-specified year against historical data on a daily basis.
historical_range.swmprCompare a user-specified year against historical data on a monthly/seasonal basis.
raw_boxplot.swmprGenerate a monthly/seasonal boxplots of raw data for a target year.
seasonal_barplot.swmprGenerate monthly/seasonal barplot for parameters that are better viewed in on a cumulative basis (e.g. precipitation).
seasonal_boxplot.swmprGenerate 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.swmprPlot average/min/max seasonal values faceted by season.
sk_seasonal.swmprSeasonal Kendall non-parametric test for monotonic seasonal trends.
threshold_criteria_plot.swmprCompare raw data against user-specified water quality thresholds
threshold_identification.swmprIdentify 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.swmprCompare raw data against user-specified percentiles calculated from historical data. User has the option to calculate percentiles on a monthly basis.
threshold_summary.swmprSummarize the results from threshold_identification in either a plot or tabular format. Results can be aggregated on a monthly, seasonal, or annual basis.

Mapping

national_sk_mapCreate a base map for NERRS reserves in ggplot with seasonal kendall results.
res_custom_mapCreate a stylized reserve-level map of custom station locations for use with the reserve level reporting template.
res_custom_sk_mapCreate a stylized reserve-level map of seasonal kendall results from custom station locations for use with the reserve level reporting template.
res_local_mapCreate a stylized reserve-level map for use with the reserve level reporting template.
res_national_mapCreate a base map for NERRS reserves in ggplot.
res_sk_mapCreate a stylized reserve-level map of seasonal kendall results for use with the reserve level reporting template.

Retrieve

in the SWMPr package, retrieve functions help the user load SWMP data into R.

import_local_nutA 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.

Reporting

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.

Reserve Level Template

create_sk_flextable_listCreate a list of flextable objects to display Seasonal Kendall results in the NERRS reserve level template.
geographic_unique_stationsCreates an alphabetically sorted, vector of geographically unique stations for mapping. Intended for use with res_local_map.
get_reserveReturn the full name of the reserve associated with the data files in the 'data' folder of the reserve level template.
get_shp_nameReturn the name of the shape file associated with the data files in the 'data' folder of the reserve level template.
get_site_codeReturn the 3 letter reserve code associated with the reserve.
get_site_coordinatesReturn the station coordinates for stations associated with the data files in the 'data' folder of the reserve level template.
get_sitesReturn the stations associated with the data files in 'data' folder of the reserve level template.
load_shp_fileLoad and format shapefile for use with res_local_map.

National Level Template

create_sk_national_ft_reservesCreate a flextable of reserve names for use with the NERRS national level template.
create_sk_national_ft_resultsCreate a flextable object to display Seasonal Kendall results for each reserve in the NERRS national level template.
summarise_handoff_filesSummarise the seasonal kendall results from reserve level report hand-off files.

Miscellaneous

Miscellaneous functions are generally helper functions that are called internally by other analysis functions.

Analyze

assign_seasonAssign 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_labsGenerate 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_labsSelect reasonable labels for breaks used in scale_x_datetime. Used internally by several analysis functions.
set_date_breaksA helper function to select reasonable breaks for scale_x_datetime. Used internally by several analysis functions.
sk_tidyTidy results from EnvStats::kendallSeasonalTrendTest. Used by sk_seasonal.swmpr to tidy seasonal kendall test results.
std_param_checkDetermine if a parameter is one of the standard SWMP parameters.
title_labelerGenerate a plot title based on SWMP station abbreviation. Used internally by several analysis functions.
y_count_labelerGenerate a y-axis label based on SWMP parameter abbreviation. Used internally by several analysis functions.
y_labelerGenerate a y-axis label based on SWMP parameter abbreviation and threshold criteria. Used internally by several analysis functions.

Mapping

reserve_locsCreate a dataframe of selected NERRS locations for plotting with res_national_map.

Reporting

ft_col_namesConvert SWMPr parameter abbreviations into formats appropriate for use with NERRS reserve level template flextable. Used internally by create_sk_flextable_list.
generate_results_tableFilters a data.frame of user-specified results for display in the NERRS reserve level report. Used internally by create_sk_flextable_list.
generate_station_tableFilters 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_nanRemoves -Inf, Inf, and NaN from a matrix. Used internally by several functions to prevent plotting errors.

Datasets

The following data sets are included within the SWMPrExtension package. They are used for examples and for mapping.

cbm_spatialA shapefile of the reserve boundary for Chesapeake Bay-Maryland NERR. Available from: http://cdmo.baruch.sc.edu/.
elk_spatialA shapefile of the reserve boundary for Elkhorn Slough NERR. Available from: http://cdmo.baruch.sc.edu/.
elknmnutNutrient data (2007-2016) from North Marsh station at Elkhorn Slough NERR.
elksmwqWater quality data (2007-2016) from South Marsh station at Elkhorn Slough NERR.
sampling_stationsMetadata 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_4269US County boundaries from the US Census Bureau's MAF/TIGER geographic database, in projection EPSG = 4269. Used to create national-level maps.



padilla410/SWMPrExtension documentation built on Dec. 29, 2021, 5:48 a.m.