Skip to contents

length(levels(x)) is the same as nlevels(x), but harder to read.

Usage

length_levels_linter()

See also

linters for a complete list of linters available in lintr.

Examples

# will produce lints
lint(
  text = "length(levels(x))",
  linters = length_levels_linter()
)
#> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[length_levels_linter] nlevels(x) is better than length(levels(x)).

# okay
lint(
  text = "length(c(levels(x), levels(y)))",
  linters = length_levels_linter()
)