Check, if vector is categorical, i.e. if is logical, factor, character or integer

is_categorical(x)

Arguments

x

A vector of arbitrary type

Value

Logical value

Examples

is_categorical(c(TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE))
#> [1] TRUE
is_categorical(1:10)
#> [1] TRUE
is_categorical((1:10) + 0.1)
#> [1] FALSE
is_categorical(as.factor(c("Ferrari", "Lamborghini", "Porsche", "McLaren", "Koenigsegg")))
#> [1] TRUE
is_categorical(c("Ferrari", "Lamborghini", "Porsche", "McLaren", "Koenigsegg"))
#> [1] TRUE