countFactorLevels: Count the number of factor levels.

countFactorLevelsR Documentation

Count the number of factor levels.

Description

countFactorLevels summarizes a data frame, a list, or a factor by computing the number of declared and used factor levels in it (in case of factors) or its constituents (in case of data frames and lists).

Usage

countFactorLevels(x)

Arguments

x

a data frame, a list, or a factor

Value

a data frame having the columns of x and two rows ('all', 'used') holding numbers of all (used) factor levels in individual columns of x

Author(s)

Tomas Sieger

Examples

if (require(MASS)) {
  countFactorLevels(Cars93)

  # omitting the first row results in some levels of \code{Cars$Model} and
  # \code{Cars93$Make} unused (and reported in the second row)
  countFactorLevels(Cars93[-1L, ])

  countFactorLevels(Cars93$Model[-1L])
  }

tsieger/tsiMisc documentation built on Oct. 10, 2023, 10:24 p.m.