A checkFunction that checks if v
is a key, that is, if every observation has a unique value in v and
v is not a numeric/integer nor a Date variable. This
function is intended for use as a precheck in makeDataReport.
isKey(v)
| v | A variable (vector) to check. All variable types are allowed. |
|---|
A checkResult with three entires:
$problem (a logical indicating whether v is a key),
$message (if a problem was found, the following message:
"The variable is a key (distinct values for each observation).",
otherwise "") and $problemValues (always NULL).
Note that numeric or integer variables are not considered candidates for keys, as truly continuous measurements will most likely result in unique values for each observation.
keyVar <- c("a", "b", "c", "d", "e", "f") notKeyVar <- c("a", "a", "b", "c", "d", "e", "f") isKey(keyVar)#> The variable is a key (distinct values for each observation).isKey(notKeyVar)#> No problems found.