This adapts code from R base summary.factor. It adds the calculation of entropy as a measure of diversity.
summary.factor(y, maxLevels = 5, stats = TRUE)
a factor (non-numeric variable)
The maximum number of levels that will be presented in the tabulation.
If TRUE (default), entropy (diversity) and normedEntropy will be included. If false, return object will include stats = NULL object.
A list, including the summary table, and vector of summary
stats if requested, c(entropy, normedEntropy)
.