Learn R Programming

dataMaid (version 1.4.2)

identifyNums: A checkFunction

Description

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

Usage

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

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

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.

See Also

check, allCheckFunctions, checkFunction, checkResult

Examples

Run this code
 #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))


Run the code above in your browser using DataLab