A checkFunction
to be called from
check
for identifying numeric variables that have
been misclassified as categorical.
identifyNums(v, nVals = 12, ...)
v | A character, factor, or labelled variable to check. |
---|---|
nVals | An integer determining how many unique values a variable must have
before it can potentially be determined to be a misclassified numeric variable.
The default is |
... | Not in use. |
A checkResult
with three entires:
$problem
(a logical indicating the variable is suspected to be
a misclassified numeric variable), $message
(if a problem was found,
the following message: "Note: The variable consists exclusively of numbers and takes
a lot of different values. Is it perhaps a misclassified numeric variable?",
otherwise "") and $problemValues
(always NULL
).
A categorical variable is suspected to be a misclassified
numeric variable if it has the following two properties: First,
it should consist exclusively of numbers (possibly including signs
and decimals points). Secondly, it must have at least nVals
unique values.
The default values of nVals
is 12, which means that
e.g. variables including answers on a scale from 0-10 will
not be recognized as misclassified numerics.
#Positive and negative numbers, saved as characters identifyNums(c(as.character(-9:9)))#> Note: The variable consists exclusively of numbers and takes a lot of different values. Is it perhaps a misclassified numeric variable?#An ordinary character variable identifyNums(c("a", "b", "c", "d", "e.f", "-a", 1:100))#> No problems found.