Description Usage Arguments References Examples
View source: R/annotate_ineq.R
Adds text annotation to chart with any inequality measure from ineq::ineq Inequality measures include Gini, RS, Atkinson, Theil, Kol, var, square.var, entropy
1 2 3 4 5 6 7 8 9 | annotate_ineq(
data_ineq,
x = 0.1,
y = 0.95,
decimals = 2,
measure_ineq = "Gini",
sep_ineq = ": ",
...
)
|
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(). |
Gini coefficient from Wikipedia
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.