View source: R/checkMWRresults.R
checkMWRresults | R Documentation |
Check water quality monitoring results
checkMWRresults(resdat, warn = TRUE)
resdat |
input data frame for results |
warn |
logical to return warnings to the console (default) |
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 blank
Activity 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
or WQX Parameter
columns of the paramsMWR
data (warning only)
Result Value: Should be a numeric value or a text value as AQL or BDL
Non-numeric Quantitation Limit: All values should be numbers, excluding missing values
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 blank
Single Result Unit: Each unique parameter in Characteristic Name
should have only one entry in Result Unit
(excludes entries for lab spikes reported as %
or % recovery
)
Correct Result Unit: Each unique parameter in Characteristic Name
should have an entry in Result Unit
that matches one of the acceptable values in the Units of measure
column of the paramsMWR
data (excludes entries for lab spikes reported as %
or % recovery
)
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.