This adapts code from R base summary.factor. It adds the calculation of entropy as a measure of diversity.
summary.factor(y, maxLevels = 5, sumstat = TRUE)a factor (non-numeric variable)
The maximum number of levels that will be presented in the tabulation.
If TRUE (default), entropy (diversity) estimate and the number of NAs will be returned.
a vector of named elements including the summary table as well as entropy and normed entropy.