Description Usage Arguments Value Examples
This function plots a Lorenz curve. Following 'Bernasco, W. and W. Steenbeek (2017). More places than crimes: Implications for evaluating the law of crime concentration at place. Journal of Quantitative Criminology. https://doi.org/10.1007/s10940-016-9324-7', if # events < # units of analysis, vertical lines are added to the plot to indicate the percentage of units of analysis where events could occur under maximum equality.
1 |
mydata |
a vector of N units, with counts of events per unit. The vector should contain at least non-negative elements. The result will be NA, if the vector contains negative elements. |
prop |
logical. Should the axes show proportions from 0 - 1 (default = TRUE), or percentages 0 - 100? |
rescale |
logical. Should the plot be rescaled so that 'c/n' is moved to the end of the x-axis and the plot is stretched out accordingly? |
returns a Lorenz curve plot (generated by ggplot2)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Plot a Lorenz curve of a non-sparse data situation:
# 10 units of analysis and 100 events
crimes <- c(22,18,17,12,11,8,6,3,2,1)
lorenz(crimes)
# Because sum(crimes) > length(crimes), it is the normal Lorenz curve.
# Plot a Lorenz curve of a sparse data situation:
# 10 units of analysis and 5 events
crimes <- c(3,1,1,rep(0,7))
lorenz(crimes)
# You can rescale the plot so that 'c/n' is moved to the end of the x-axis
# (and the graph is stretched to the right accordingly)
lorenz(crimes, rescale = TRUE)
# Rescaling the graph is easier with very sparse data situation, as the
# adjusted line of maximal equality can become almost vertical from origin:
crimes <- c(3,1,1,rep(0,150))
lorenz(crimes)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.