tabMWRacc {MassWateR} | R Documentation |
Create a formatted table of quality control accuracy checks
Description
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 |
acc |
character string of path to the data quality objectives file for accuracy or |
frecom |
character string of path to the data quality objectives file for frequency and completeness or |
fset |
optional list of inputs with elements named |
runchk |
logical to run data checks with |
warn |
logical to return warnings to the console (default) |
accchk |
character string indicating which accuracy check to return, one to any of |
type |
character string indicating |
pass_col |
character string (as hex code) for the cell color of checks that pass, applies only if |
fail_col |
character string (as hex code) for the cell color of checks that fail, applies only if |
suffix |
character string indicating suffix to append to percentage values |
caption |
logical to include a caption from |
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.
Value
A flextable
object with formatted results.
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')