isSingular: Check if a variable only contains a single value

Description Usage Arguments Value See Also Examples

View source: R/isSingular.R

Description

A checkFunction that checks if v only contains a single unique value, aside from missing values. This function is intended for use as a precheck in makeDataReport.

Usage

1
2
3

Arguments

v

A variable (vector) to check. All variable types are allowed.

Value

A checkResult with three entires: $problem (a logical indicating whether v contains only one value), $message (if a problem was found, a message describing which single value the variable takes and how many missing observations it contains, otherwise ""), and $problemValues (always NULL).

See Also

check, allCheckFunctions, checkFunction, checkResult

Examples

1
2
3
4
5
singularVar <- c(rep("a", 10), NA, NA)
notSingularVar <- c("a", "a", "b", "c", "d", "e", "f", NA, NA)

isSingular(singularVar)
isSingular(notSingularVar)

ekstroem/cleanR documentation built on Jan. 31, 2022, 8:58 a.m.