Lc() from the ineq package computes Lorenz-curve statistics for a numeric distribution. Pair it with base R's plot() to visualize inequality in data such as NBA player win shares. section 13.6.2
A practical workflow prepares the distribution before plotting:
- Filter the desired years, reshape win shares into one column per year, remove identifiers, and convert the result to a data frame. section 13.6.2
- Loop across the four year columns, pass each numeric vector to Lc(), and create a titled Lorenz-curve plot. section 13.6.2
Plot four years of win-share inequality
With the prepared ws9194 data frame, par(mfrow = c(2, 2)) arranges four panels. The loop assigns each column to x and plots Lc(x), producing Lorenz curves for 1991 through 1994. section 13.6.2
par(mfrow = c(2, 2))
loop.vector <- 1:4
for (i in loop.vector) {
x <- ws9194[,i]
plot(Lc(x), col = "red", lwd = 2,
main = paste0("Lorenz Curve\n", "199", i),
xlab = "Win Share Distribution",
ylab = "Percentage of NBA Players")
}
Inspect the executable loop that applies Lc() to each year and labels the resulting plots. section 13.6.2
