| checkMWRacc {MassWateR} | R Documentation |
Check data quality objective accuracy data
Description
Check data quality objective accuracy data
Usage
checkMWRacc(accdat, warn = TRUE)
Arguments
accdat |
input data frame |
warn |
logical to return warnings to the console (default) |
Details
This function is used internally within readMWRacc to run several checks on the input data for completeness and conformance to WQX requirements
The following checks are made:
Column name spelling: Should be the following: Parameter, uom, MDL, UQL, Value Range, Field Duplicate, Lab Duplicate, Field Blank, Lab Blank, Spike/Check Accuracy
Columns present: All columns from the previous check should be present
Column types: All columns should be characters/text, except for MDL and UQL
-
Value Rangecolumn na check: The character string"na"should not be in theValue Rangecolumn,"all"should be used if the entire range applies Unrecognized characters: Fields describing accuracy checks should not include symbols or text other than
<=,\leq,<,>=,\geq,>,\pm,"%","BDL","AQL","log", or"all"Overlap in
Value Rangecolumn: Entries inValue Rangeshould not overlap for a parameter (excludes ascending ranges)Gap in
Value Rangecolumn: Entries inValue Rangeshould not include a gap for a parameter, warning onlyParameter: Should match parameter names in the
Simple ParameterorWQX Parametercolumns of theparamsMWRdataUnits: No missing entries in units (
uom), except pH which can be blankSingle unit: Each unique
Parametershould have only one type for the units (uom)Correct units: Each unique
Parametershould have an entry in the units (uom) that matches one of the acceptable values in theUnits of measurecolumn of theparamsMWRdataEmpty columns: Columns with all missing or NA values will return a warning
Value
accdat is returned as is if no errors are found, otherwise an informative error message is returned prompting the user to make the required correction to the raw data before proceeding.
Examples
# accuracy path
accpth <- system.file('extdata/ExampleDQOAccuracy.xlsx',
package = 'MassWateR')
# accuracy data with no checks
accdat <- readxl::read_excel(accpth, na = c('NA', ''), col_types = 'text')
accdat <- dplyr::mutate(accdat, dplyr::across(-c(`Value Range`), ~ dplyr::na_if(.x, 'na')))
checkMWRacc(accdat)