Skip to contents

Create a formatted table of quality control accuracy checks

Usage

tabMWRacc(
  res = NULL,
  acc = NULL,
  frecom = NULL,
  fset = NULL,
  runchk = TRUE,
  warn = TRUE,
  accchk = c("Field Blanks", "Lab Blanks", "Field Duplicates", "Lab Duplicates",
    "Lab Spikes / Instrument Checks"),
  type = c("individual", "summary", "percent"),
  pass_col = "#57C4AD",
  fail_col = "#DB4325",
  suffix = "%",
  caption = TRUE
)

Arguments

res

character string of path to the results file or data.frame for results returned by readMWRresults

acc

character string of path to the data quality objectives file for accuracy or data.frame returned by readMWRacc

frecom

character string of path to the data quality objectives file for frequency and completeness or data.frame returned by readMWRfrecom, applies only if type = "summary" or type = "percent"

fset

optional list of inputs with elements named res, acc, frecom, sit, or wqx overrides the other arguments

runchk

logical to run data checks with checkMWRresults and checkMWRacc, applies only if res or acc are file paths

warn

logical to return warnings to the console (default)

accchk

character string indicating which accuracy check to return, one to any of "Field Blanks", "Lab Blanks", "Field Duplicates", "Lab Duplicates", or "Lab Spikes / Instrument Checks"

type

character string indicating individual, summary or percent tabular output, see details

pass_col

character string (as hex code) for the cell color of checks that pass, applies only if type = 'percent'

fail_col

character string (as hex code) for the cell color of checks that fail, applies only if type = 'percent'

suffix

character string indicating suffix to append to percentage values

caption

logical to include a caption from accchk, only applies if type = "individual"

Value

A flextable object with formatted results.

Details

The function can be used with inputs as paths to the relevant files or as data frames returned by readMWRresults and readMWRacc. For the former, the full suite of data checks can be evaluated with runkchk = T (default) or suppressed with runchk = F, as explained in the relevant help files. In the latter case, downstream analyses may not work if data are formatted incorrectly. For convenience, a named list with the input arguments as paths or data frames can be passed to the fset argument instead. See the help file for utilMWRinput.

Also note that accuracy is only evaluated on parameters that are shared between the results file and data quality objectives file for accuracy. A warning is returned for parameters that do not match between the files. This warning can be suppressed by setting warn = FALSE.

The function can return three types of tables as specified with the type argument: "individual", "summary", or "percent". The individual tables are specific to each type of accuracy check for each parameter (e.g., field blanks, lab blanks, etc.). The summary table summarizes all accuracy checks by the number of checks and how many hit/misses are returned for each across all parameters. The percent table is similar to the summary table, but showing only percentages with appropriate color-coding for hit/misses. The data quality objectives file for frequency and completeness is required if type = "summary" or type = "percent".

For type = "individual", the quality control tables for accuracy are retrieved by specifying the check with the accchk argument. The accchk argument can be used to specify one of the following values to retrieve the relevant tables: "Field Blanks", "Lab Blanks", "Field Duplicates", "Lab Duplicates", or "Lab Spikes / Instrument Checks".

For type = "summary", the function summarizes all accuracy checks by counting the number of quality control checks, number of misses, and percent acceptance for each parameter. All accuracy checks are used and the accchk argument does not apply.

For type = "percent", the function returns a similar table as for the summary option, except only the percentage of checks that pass for each parameter are shown in wide format. Cells are color-coded based on the percentage of checks that have passed using the percent thresholds from the % Completeness column of the data quality objectives file for frequency and completeness. Parameters without an entry for % Completeness are not color-coded and an appropriate warning is returned. All accuracy checks are used and the accchk argument does not apply.

Inputs for the results and data quality objectives for accuracy are processed internally with qcMWRacc and the same arguments are accepted for this function, in addition to others listed above.

Examples


##
# using file paths

# results path
respth <- system.file('extdata/ExampleResults.xlsx', package = 'MassWateR')

# accuracy path
accpth <- system.file('extdata/ExampleDQOAccuracy.xlsx', 
     package = 'MassWateR')

# frequency and completeness path
frecompth <- system.file('extdata/ExampleDQOFrequencyCompleteness.xlsx', 
     package = 'MassWateR')

# table as individual
tabMWRacc(res = respth, acc = accpth, frecom = frecompth, type = 'individual', 
     accchk = 'Field Blanks')
#> Running checks on results data...
#> 	Checking column names... OK
#> 	Checking all required columns are present... OK
#> 	Checking valid Activity Types... OK
#> 	Checking Activity Start Date formats... OK
#> 	Checking depth data present... OK
#> 	Checking for non-numeric values in Activity Depth/Height Measure... OK
#> 	Checking Activity Depth/Height Unit... OK
#> 	Checking Activity Relative Depth Name formats... OK
#> 	Checking values in Activity Depth/Height Measure > 1 m / 3.3 ft... OK
#> 	Checking Characteristic Name formats... OK
#> 	Checking Result Values... OK
#> 	Checking for non-numeric values in Quantitation Limit... OK
#> 	Checking QC Reference Values... OK
#> 	Checking for missing entries for Result Unit... OK
#> 	Checking if more than one unit per Characteristic Name... OK
#> 	Checking acceptable units for each entry in Characteristic Name... OK
#> 
#> All checks passed!
#> Running checks on data quality objectives for accuracy...
#> 	Checking column names... OK
#> 	Checking all required columns are present... OK
#> 	Checking column types... OK
#> 	Checking no "na" in Value Range... OK
#> 	Checking for text other than <=, ≤, <, >=, ≥, >, ±, %, AQL, BQL, log, or all... OK
#> 	Checking overlaps in Value Range... OK
#> 	Checking gaps in Value Range... OK
#> 	Checking Parameter formats... OK
#> 	Checking for missing entries for unit (uom)... OK
#> 	Checking if more than one unit (uom) per Parameter... OK
#> 	Checking acceptable units (uom) for each entry in Parameter... OK
#> 	Checking empty columns... OK
#> 
#> All checks passed!
#> Running checks on data quality objectives for frequency and completeness...
#> 	Checking column names... OK
#> 	Checking all required columns are present... OK
#> 	Checking for non-numeric values... OK
#> 	Checking for values outside of 0 and 100... OK
#> 	Checking Parameter formats... OK
#> 	Checking empty columns... OK
#> 
#> All checks passed!
Field Blanks

Parameter

Date

Site

Result

Threshold

Hit/Miss

Ammonia

2022-05-15

BDL

0.1 mg/l

2022-06-12

BDL

0.1 mg/l

2022-07-17

BDL

0.1 mg/l

2022-07-17

BDL

0.1 mg/l

2022-08-14

BDL

0.1 mg/l

2022-08-14

BDL

0.1 mg/l

2022-09-11

BDL

0.1 mg/l

E.coli

2022-06-13

BDL

1 MPN/100ml

2022-07-18

BDL

1 MPN/100ml

2022-08-01

BDL

1 MPN/100ml

2022-08-29

BDL

1 MPN/100ml

Nitrate

2022-05-15

BDL

0.05 mg/l

2022-06-12

BDL

0.05 mg/l

2022-06-12

BDL

0.05 mg/l

2022-07-17

BDL

0.05 mg/l

2022-07-17

BDL

0.05 mg/l

2022-08-14

BDL

0.05 mg/l

2022-09-11

BDL

0.05 mg/l

TP

2022-05-15

BDL

0.01 mg/l

2022-05-15

BDL

0.01 mg/l

2022-06-12

BDL

0.01 mg/l

2022-06-12

BDL

0.01 mg/l

2022-07-17

BDL

0.01 mg/l

2022-07-17

BDL

0.01 mg/l

2022-07-17

0.01 mg/l

0.01 mg/l

MISS

2022-08-14

BDL

0.01 mg/l

2022-08-14

BDL

0.01 mg/l

2022-09-11

BDL

0.01 mg/l

2022-09-11

BDL

0.01 mg/l