identifyNums: A checkFunction

Description Usage Arguments Details Value See Also Examples

View source: R/identifyNums.R

Description

A checkFunction to be called from check for identifying numeric variables that have been misclassified as categorical.

Usage

1
identifyNums(v, nVals = 12, ...)

Arguments

v

A character, factor, or (haven_)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 12.

...

Not in use.

Details

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.

Value

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).

See Also

check, allCheckFunctions, checkFunction, checkResult

Examples

1
2
3
4
5
 #Positive and negative numbers, saved as characters
 identifyNums(c(as.character(-9:9)))

 #An ordinary character variable
 identifyNums(c("a", "b", "c", "d", "e.f", "-a", 1:100))

dataReporter documentation built on Nov. 11, 2021, 9:06 a.m.