| isKey {dataMaid} | R Documentation |
Check if a variable qualifies as a key
Description
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.
Usage
isKey(v)
Arguments
v |
A variable (vector) to check. All variable types are allowed. |
Details
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.
Value
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).
See Also
check, allCheckFunctions,
checkFunction, checkResult
Examples
keyVar <- c("a", "b", "c", "d", "e", "f")
notKeyVar <- c("a", "a", "b", "c", "d", "e", "f")
isKey(keyVar)
isKey(notKeyVar)