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 Range
column na check: The character string"na"
should not be in theValue Range
column,"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 Range
column: Entries inValue Range
should not overlap for a parameter (excludes ascending ranges)Gap in
Value Range
column: Entries inValue Range
should not include a gap for a parameter, warning onlyParameter: Should match parameter names in the
Simple Parameter
orWQX Parameter
columns of theparamsMWR
dataUnits: No missing entries in units (
uom
), except pH which can be blankSingle unit: Each unique
Parameter
should have only one type for the units (uom
)Correct units: Each unique
Parameter
should have an entry in the units (uom
) that matches one of the acceptable values in theUnits of measure
column of theparamsMWR
dataEmpty 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)