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).

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

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]) }
#> Loading required package: MASS
#> Loading required package: grDevices
#> x #> all 93 #> used 92