Skip to contents

Whether or not a vector is a discrete variable, returns a logical. Typically used on the Y variable of a model.

Usage

is_discrete(x, na.rm = TRUE)

Arguments

x

A vector to check the discreteness of.

na.rm

Whether or not to remove NA values before testing discreteness. Defaults to TRUE.

Value

Logical, whether or not x is a discrete variable.

Examples

library(cheem)

is_discrete(mtcars$mpg) ## Numeric column, with more than 25 unique values.
#> [1] FALSE
is_discrete(mtcars$cyl) ## Numeric column, labeled as discrete, because less than 25 unique values
#> [1] TRUE
is_discrete(letters)    ## Characters and factors labeled discrete.
#> [1] TRUE