Learn R Programming

SciencesPo (version 1.3.9)

gini: Weighted Gini Index

Description

Computes the unweighted and weighted Gini index of a distribution.

Usage

gini(x, weights = rep(1, length = length(x)), ...)

gini(x, weights = rep(1, length = length(x)), ...)

Arguments

x
A data.frame, a matrix-like, or a vector.
weights
A vector containing weights for x.
...
Additional arguements (currently ignored)

encoding

UTF-8

See Also

gini.simpson.

Examples

Run this code
# generate a vector (of incomes)
x <- c(778, 815, 857, 888, 925, 930, 965, 990, 1012)
# compute Gini index
gini(x)

gini(c(100,0,0,0))

Run the code above in your browser using DataLab