Checks that an argument is a single non-missing character string.
Meant for the labelling arguments across the suite - dataName,
captions, axis titles - where a vector or an NA would otherwise
travel unnoticed into printed output.
Usage
checkString(x, name = deparse(substitute(x)))Details
An optional argument that may also be NULL is guarded by the
caller, if (!is.null(dataName)) checkString(dataName), rather than
by a further argument here: whether the absence of a label is
admissible is a decision of the function, not of the check.
The empty string is accepted. It is a legitimate label, and a caller that needs a non-empty one says so itself.
Examples
dataName <- "smoking by sex"
checkString(dataName)
if (FALSE) { # \dontrun{
checkString(NA_character_) # a missing label is not a label
checkString(c("a", "b")) # length
checkString(42) # type
} # }
