Learn R Programming

rockchalk (version 1.8.111)

summary.factor: Tabulates observed values and calculates entropy

Description

This adapts code from R base summary.factor. It adds the calculation of entropy as a measure of diversity.

Usage

summary.factor(y, maxLevels = 5, stats = TRUE)

Arguments

y

a factor (non-numeric variable)

maxLevels

The maximum number of levels that will be presented in the tabulation.

stats

If TRUE (default), entropy (diversity) and normedEntropy will be included. If false, return object will include stats = NULL object.

Value

A list, including the summary table, and vector of summary stats if requested, c(entropy, normedEntropy).