checkMWRresults {MassWateR} | R Documentation |
Check water quality monitoring results
Description
Check water quality monitoring results
Usage
checkMWRresults(resdat, warn = TRUE)
Arguments
resdat |
input data frame for results |
warn |
logical to return warnings to the console (default) |
Details
This function is used internally within readMWRresults
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: Monitoring Location ID, Activity Type, Activity Start Date, Activity Start Time, Activity Depth/Height Measure, Activity Depth/Height Unit, Activity Relative Depth Name, Characteristic Name, Result Value, Result Unit, Quantitation Limit, QC Reference Value, Result Measure Qualifier, Result Attribute, Sample Collection Method ID, Project ID, Local Record ID, Result Comment
Columns present: All columns from the previous check should be present
Activity Type: Should be one of Field Msr/Obs, Sample-Routine, Quality Control Sample-Field Blank, Quality Control Sample-Lab Blank, Quality Control Sample-Lab Duplicate, Quality Control Sample-Lab Spike, Quality Control-Calibration Check, Quality Control-Meter Lab Duplicate, Quality Control-Meter Lab Blank
Date formats: Should be mm/dd/yyyy and parsed correctly on import
Depth data present: Depth data should be included in Activity Depth/Height Measure or Activity Relative Depth Name for all rows where Activity Type is Field Msr/Obs or Sample-Routine
Non-numeric Activity Depth/Height Measure: All depth values should be numbers, excluding missing values
Activity Depth/Height Unit: All entries should be
ft
,m
, or blankActivity Relative Depth Name: Should be either Surface, Bottom, Midwater, Near Bottom, or blank (warning only)
Activity Depth/Height Measure out of range: All depth values should be less than or equal to 1 meter / 3.3 feet or entered as Surface in the Activity Relative Depth Name column (warning only)
Characteristic Name: Should match parameter names in the
Simple Parameter
orWQX Parameter
columns of theparamsMWR
data (warning only)Result Value: Should be a numeric value or a text value as AQL or BDL
QC Reference Value: Should be a numeric value or a text value as AQL or BDL
Result Unit: No missing entries in
Result Unit
, except pH which can be blankSingle Result Unit: Each unique parameter in
Characteristic Name
should have only one entry inResult Unit
(excludes entries for lab spikes reported as%
or% recovery
)Correct Result Unit: Each unique parameter in
Characteristic Name
should have an entry inResult Unit
that matches one of the acceptable values in theUnits of measure
column of theparamsMWR
data (excludes entries for lab spikes reported as%
or% recovery
)
Value
resdat
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. Checks with warnings can be fixed at the discretion of the user before proceeding.
Examples
library(dplyr)
respth <- system.file('extdata/ExampleResults.xlsx', package = 'MassWateR')
resdat <- suppressWarnings(readxl::read_excel(respth, na = c('NA', 'na', ''), guess_max = Inf)) %>%
dplyr::mutate_if(function(x) !lubridate::is.POSIXct(x), as.character)
checkMWRresults(resdat)