checkSummary: Summarize a vector of check results

Description Usage Arguments Value Examples

Description

One check test results in an empty string, an NA, or error message. Multiple test checks can be merged into a vector with each element named for a test and giving its outcome. This can then be summarized into a single check result by merging error strings if any, reporting an empty string if everything passed, and handling NA's as either errors or ignoring them.

Usage

1
checkSummary(result, naOk = NULL, skip = NULL)

Arguments

result

A vector of check results, with element values being an empty string (success), a failure string, or NA_character_. Elements are named for the test they represent.

naOk

A vector of the names of elements for which NA is ok. If NA is ok for every element, then set this to names(result). By default, this is NULL and missing values are converted to failures for every test.

skip

A vector of the names of elements to be left out of the summary, regardless of their value. By default all elements are considered and used.

Value

As other check functions, this returns a single character string which is empty if the check succeeds and contains a failure message if the the check fails. However, here success means all tests not skipped succeed. Missing values are by default considered failures. A failure message is reported if any element failed.

The failure message is formated like "<testName> = <error message>; ..." where each element with a failing message, from first to last, are reported and joined by '; '. If an element has a missing value, it will first be converted to the failure string "NA not ok." before summarizing, unless its test name is provided in a string vector as naOk (or as skip, except then its value will be ignored even if it failed.)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
fauxChecks <- c('', '', '')
names(fauxChecks) <- c('checkA', 'checkB', 'checkC')
checkSummary(fauxChecks)
#=> [1] ""
fauxChecks['checkC'] <- NA_character_
checkSummary(fauxChecks)
#=> [1] "checkC = NA not ok."
checkSummary(fauxChecks, naOk= c('checkC'))
#=> [1] ""
fauxChecks['checkB'] <- 'I am broken.'
checkSummary(fauxChecks)
#=> [1] "checkB = I am broken.; checkC = NA not ok."
checkSummary(fauxChecks, naOk= c('checkB', 'checkC'))
#=> [1] "checkB = I am broken."
checkSummary(fauxChecks, skip= c('checkB', 'checkC'))
#=> [1] ""

jefferys/DataRepo documentation built on May 19, 2019, 3:58 a.m.