-
Notifications
You must be signed in to change notification settings - Fork 2
/
annotate_ineq.Rd
62 lines (51 loc) · 1.73 KB
/
annotate_ineq.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/annotate_ineq.R
\name{annotate_ineq}
\alias{annotate_ineq}
\title{Annotate ggplot2 chart with inequality metric}
\usage{
annotate_ineq(
data_ineq,
freq_ineq = rep(1, length(data_ineq)),
x = 0.1,
y = 0.95,
decimals = 2,
measure_ineq = "Gini",
sep_ineq = ": ",
...
)
}
\arguments{
\item{data_ineq}{Data to calculate the inequality metric on.}
\item{freq_ineq}{(optional) Frequency of each observation, defaults to 1, should be same length as data}
\item{x}{annotation x-axis position, defaults to 0.1.}
\item{y}{annotation y-axis position, defaults to 0.95.}
\item{decimals}{number of decimals to show, defaults to 2.}
\item{measure_ineq}{Name of measure to use; defaults to Gini.}
\item{sep_ineq}{text separator between annotation label and value.}
\item{...}{any additional parameters to ggplot2::annotate().}
}
\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
}
\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")
\dontrun{
ggplot(freqdata, aes(x=value, n=freq)) +
stat_lorenz() +annotate_ineq(freqdata$val, freqdata$freq)}
}
\references{
\href{https://en.wikipedia.org/wiki/Gini_coefficient}{Gini coefficient from Wikipedia}
}