annotate_ineq {gglorenz} | R Documentation |
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")
[Package gglorenz version 0.0.2 Index]