Title: | Plotting Lorenz Curve with the Blessing of 'ggplot2' |
Version: | 0.0.2 |
Description: | Provides statistical transformations for plotting empirical ordinary Lorenz curve (Lorenz 1905) <doi:10.2307/2276207> and generalized Lorenz curve (Shorrocks 1983) <doi:10.2307/2554117>. |
Depends: | R (≥ 3.2.0), ggplot2 (≥ 2.2.1) |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
LazyData: | true |
URL: | https://github.com/jjchern/gglorenz |
BugReports: | https://github.com/jjchern/gglorenz/issues |
RoxygenNote: | 7.1.0 |
Imports: | ineq |
Suggests: | spelling |
Language: | en-US |
NeedsCompilation: | no |
Packaged: | 2020-05-27 01:03:21 UTC; chan |
Author: | JJ Chen |
Maintainer: | JJ Chen <jiajia.chern@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2020-05-27 09:00:06 UTC |
Annotate ggplot2 chart with inequality metric
Description
Adds text annotation to chart with any inequality measure from ineq::ineq Inequality measures include Gini, RS, Atkinson, Theil, Kol, var, square.var, entropy
Usage
annotate_ineq(
data_ineq,
x = 0.1,
y = 0.95,
decimals = 2,
measure_ineq = "Gini",
sep_ineq = ": ",
...
)
Arguments
data_ineq |
Data to calculate the inequality metric on. |
x |
annotation x-axis position, defaults to 0.1. |
y |
annotation y-axis position, defaults to 0.95. |
decimals |
number of decimals to show, defaults to 2. |
measure_ineq |
Name of measure to use; defaults to Gini. |
sep_ineq |
text separator between annotation label and value. |
... |
any additional parameters to ggplot2::annotate(). |
References
Gini coefficient from Wikipedia
Examples
library(gglorenz)
ggplot(billionaires, aes(TNW)) +
stat_lorenz() +
annotate_ineq(billionaires$TNW)
ggplot(billionaires, aes(TNW)) +
stat_lorenz(desc = TRUE) +
geom_abline(linetype = "dashed") +
theme_bw() +
annotate_ineq(billionaires$TNW, measure_ineq = "RS", color = "red",
family = theme_get()$text[["family"]],
size = theme_get()$text[["size"]] / 2,
fontface = "italic")
Billionaires data
Description
Contains 500 billionaires' name, country, industry, and total net worth. The data is collected in Feb. 8, 2018.
Usage
billionaires
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 500 rows and 6 columns.
Source
https://www.bloomberg.com/billionaires/
gglorenz: Plotting Lorenz Curve with ggplot2
Description
The package provides statistical transformations for plotting empirical ordinary Lorenz curve and generalized Lorenz curve.
Author(s)
JJ Chen
Values of Ordinary Lorenz Curve
Description
Provides ordinary Lorenz curve values for line plots
Usage
stat_lorenz(
mapping = NULL,
data = NULL,
geom = "path",
position = "identity",
...,
desc = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
which geom to use; defaults to " |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
desc |
If FALSE, the default, the population is arranged in ascending order along the x-axis. If TRUE, the population is arranged in descending order. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
References
Examples
library(gglorenz)
ggplot(billionaires, aes(TNW)) +
stat_lorenz()
ggplot(billionaires, aes(TNW)) +
stat_lorenz(desc = TRUE) +
coord_fixed() +
geom_abline(linetype = "dashed") +
theme_minimal()
Values of Generalized Lorenz Curve
Description
Provides generalized Lorenz curve values for line plots
Usage
stat_lorenz_generalized(
mapping = NULL,
data = NULL,
geom = "path",
position = "identity",
...,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
which geom to use; defaults to " |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
References
Examples
library(gglorenz)
ggplot(billionaires, aes(TNW)) +
stat_lorenz_generalized()