## generate vectors of industrial count
ind <- c(0, 10, 10, 30, 50)
## run the function
gini(ind)
## generate a region - industry matrix
mat <- matrix(
c(
0, 1, 0, 0,
0, 1, 0, 0,
0, 1, 0, 0,
0, 1, 0, 1,
0, 1, 1, 1
),
ncol = 4, byrow = TRUE
)
rownames(mat) <- c("R1", "R2", "R3", "R4", "R5")
colnames(mat) <- c("I1", "I2", "I3", "I4")
## run the function
gini(mat)
## run the function by aggregating all industries
gini(rowSums(mat))
## run the function for industry #1 only (perfect equality)
gini(mat[, 1])
## run the function for industry #2 only (perfect equality)
gini(mat[, 2])
## run the function for industry #3 only (perfect unequality: max gini = (5-1)/5)
gini(mat[, 3])
## run the function for industry #4 only (top 40% produces 100% of the output)
gini(mat[, 4])
Run the code above in your browser using DataLab