Learn R Programming

nomiShape (version 1.0.0)

dominance_index: Dominance Index for Nominal Variables

Description

Computes dominance for a nominal variable using the Simpson index, quantifying the degree to which a few categories dominate the distribution.

Usage

dominance_index(df, var)

Value

A numeric value representing dominance.

Arguments

df

A data.frame or tibble containing the nominal variable.

var

Character. Name of the nominal variable in df.

Details

Dominance is calculated as: $$D = \sum p_i^2$$ where \(p_i\) is the relative frequency of category \(i\).

Higher values indicate stronger dominance by fewer categories.

Examples

Run this code
dominance_index(categories, "animal")
dominance_index(categories2, "animal")
dominance_index(categories3, "animal")

Run the code above in your browser using DataLab