Skip to contents

Gini coefficient

Usage

concstats_gini(x, normalized = TRUE, na.rm = TRUE, digits = NULL)

Arguments

x

A non-negative numeric vector.

normalized

Logical. Argument specifying whether or not a normalized value is required. Must be either TRUE or FALSE. The default is TRUE.

na.rm

A logical vector that indicates whether NA values should be excluded or not. Must be either TRUE or FALSE. The default is TRUE. If set to FALSE the computation yields NA if NA values are present.

digits

An optional value for digits. Specifies the minimum number of significant digits to be printed in values. The default is NULL and will use base R print option. Significant digits defaults to 7. Values are restricted between 1 and default value.

Value

A single numeric value.

See also

Other Concentration and inequality measures: concstats_all_inequ(), concstats_entropy(), concstats_grs(), concstats_inequ(), concstats_palma(), concstats_simpson()

Examples

# a vector of market shares
x <- c(0.4, 0.2, 0.25, 0.1, 0.05)
concstats_gini(x, normalized = TRUE)
#> [1] 0.425

# a vector with NA values
x <- c(0.4, 0.2, 0.25, 0.1, 0.05, NA)
concstats_gini(x, na.rm = TRUE, digits = 2)
#> `x` has NA values. NAs have been removed for computation.
#> [1] 0.43