gini: Gini coefficient

View source: R/gini.R

giniR Documentation

Gini coefficient

Description

Takes a matrix and returns the Gini coefficient of each column.

Usage

gini(input, byrow = FALSE)

Arguments

input

A matrix where the Gini coefficient will be calculated on each column. Note that vector data must be converted to a single-column matrix.

byrow

Defaults to FALSE. Set to TRUE to calculate the Gini coefficient of each row.

Value

A vector of the Gini coefficients of each column.

References

Gini, C. (1912). Variabilita e mutabilita. Reprinted in Memorie di metodologica statistica (Ed. Pizetti E, Salvemini, T). Rome: Libreria Eredi Virgilio Veschi.

Examples

# Vectors are not supported. First convert to a single-column matrix.
sample_data <- runif(20, 0, 1)
gini(matrix(sample_data, ncol = 1))

# Multiple Gini coefficients can be calculated simultaneously
gini(matrix(sample_data, ncol = 2)) 


netcom documentation built on July 22, 2022, 1:05 a.m.