Overview
The wqformat R package converts water quality data to several different formats. It is primarily designed to format water quality data for MassWateR and WQdashboard, but it can convert data to other formats as well.
The package is created in collaboration with the Massachusetts Bays National Estuary Partnership with funding from an EPA Exchange Network Grant (Grant No. ).
Data Inputs
wqformat accepts two types of data: water quality results and site metadata. Before using wqformat, please double check that all columns and variables are spelled correctly; wqformat provides informative error messages, but will not work correctly if things are misspelled.
wqformat will:
- Rename columns
- Update variable names
wqformat will not:
- Check for QAQC errors
Converting Standard Formats
By default, wqformat accepts eight different formats, listed below.
Converting data between accepted formats is a simple process: use
format_results() to format water quality results and
format_sites() to format site metadata. These functions
will update column names, update variable names, and standardize
units.
| Format | Code | Water Quality Data |
|---|---|---|
| Blackstone River Coalition | MA_BRC | Sites, Results |
| Friends of Casco Bay | ME_FOCB | Sites, Results |
| Maine DEP | ME_DEP | Sites, Results |
| MassWateR | MassWateR | Sites, Results |
| Rhode Island DEM | RI_DEM | Results only |
| URI Watershed Watch | RI_WW | Sites, Results |
| wqdashboard | wqdashboard | Sites, Results |
| WQX | WQX | Sites, Results |
To format result data for MassWateR or WQdashboard, you may use
format_mwr_results() or format_wqd_results()
respectively.
Converting Custom Formats
wqformat includes a series of helper functions to convert data to or from a custom format.
Update Columns
To adjust column names, use rename_col() or
concat_col().
To change a column type, use col_to_numeric(),
col_to_date(), or col_to_time().
Update Variables
To update the variables within a column, use
update_var(). To check for typos or other errors, use
warn_invalid_var().
If a column contains state names, use state_to_abb() or
abb_to_state() to format all states as abbreviations or
full names respectively.
Update Units
To convert all values in a column to a unit of your choice, use
set_units().
To standardize units within a parameter type or other group, use
standardize_units() or
standardize_units_across().