## generate vectors of industrial count
ind <- c(0, 10, 10, 30, 50)
## run the function
lorenz_curve (ind)
lorenz_curve (ind, plot = FALSE)
## 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
lorenz_curve (mat)
lorenz_curve (mat, plot = FALSE)
## run the function by aggregating all industries
lorenz_curve (rowSums(mat))
lorenz_curve (rowSums(mat), plot = FALSE)
## run the function for industry #1 only (perfect equality)
lorenz_curve (mat[,1])
lorenz_curve (mat[,1], plot = FALSE)
## run the function for industry #2 only (perfect equality)
lorenz_curve (mat[,2])
lorenz_curve (mat[,2], plot = FALSE)
## run the function for industry #3 only (perfect unequality)
lorenz_curve (mat[,3])
lorenz_curve (mat[,3], plot = FALSE)
## run the function for industry #4 only (top 40% produces 100% of the output)
lorenz_curve (mat[,4])
lorenz_curve (mat[,4], plot = FALSE)
## Compare the distribution of the #industries
oldpar <- par(mfrow = c(2, 2)) # Save the current graphical parameter settings
lorenz_curve (mat[,1])
lorenz_curve (mat[,2])
lorenz_curve (mat[,3])
lorenz_curve (mat[,4])
par(oldpar) # Reset the graphical parameters to their original values
## Save output as pdf
lorenz_curve (mat, pdf = TRUE)
## To specify an output directory for the pdf,
## specify 'pdf_location', for instance as '/Users/jones/lorenz_curve.pdf'
## lorenz_curve(mat, pdf = TRUE, pdf_location = '/Users/jones/lorenz_curve.pdf')
Run the code above in your browser using DataLab