checkMWRfrecom {MassWateR} | R Documentation |
Check data quality objective frequency and completeness data
Description
Check data quality objective frequency and completeness data
Usage
checkMWRfrecom(frecomdat, warn = TRUE)
Arguments
frecomdat |
input data frame |
warn |
logical to return warnings to the console (default) |
Details
This function is used internally within readMWRfrecom
to run several checks on the input data for frequency and completeness and conformance to WQX requirements
The following checks are made:
Column name spelling: Should be the following: Parameter, Field Duplicate, Lab Duplicate, Field Blank, Lab Blank, Spike/Check Accuracy, % Completeness
Columns present: All columns from the previous check should be present
Non-numeric values: Values entered in columns other than the first should be numeric
Values outside of 0 - 100: Values entered in columns other than the first should not be outside of 0 and 100
Parameter: Should match parameter names in the
Simple Parameter
orWQX Parameter
columns of theparamsMWR
dataEmpty columns: Columns with all missing or NA values will return a warning
Value
frecomdat
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
library(dplyr)
frecompth <- system.file('extdata/ExampleDQOFrequencyCompleteness.xlsx',
package = 'MassWateR')
frecomdat <- suppressMessages(readxl::read_excel(frecompth,
skip = 1, na = c('NA', 'na', ''),
col_types = c('text', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric')
)) %>%
rename(`% Completeness` = `...7`)
checkMWRfrecom(frecomdat)