The Gini coefficient is a measure of the inequality of a distribution, most commonly used to compare inequality in income or wealth among countries.
Let’s first generate some random data to analyze. You can download my random data or use the code below to generate your own. Of course, if you generate your own, your graphs and results will be different from those shown below.
But we don’t want to replicate this code over and over to calculate the Gini coefficient for a large number of locales. We also want the coefficients to be in a data frame for easy use in R or for export for use in another program.