| gf_star {pubh} | R Documentation |
Annotating a plot to display differences between groups.
Description
gf_star Is a function used to display differences between groups (see details).
Usage
gf_star(fig, x1, y1, x2, y2, y3, legend = "*", ...)
Arguments
fig |
A gformula object. |
x1 |
Position in |
y1 |
Position in |
x2 |
Position in |
y2 |
Position in |
y3 |
Position in |
legend |
Character text used for annotating the plot. |
... |
Additional information passed to |
Details
This function draws an horizontal line from coordinate (x1, y2)
to coordinate (x2, y2). Draws vertical lines below the horizontal line,
towards data, from (x1, y1) to (x1, y2) and from
(x2, y1) to (x2, y2). Finally, adds
text above the horizontal line, at the mid point between x1 and x2.
See examples.
Examples
data(kfm, package = "ISwR")
require(sjlabelled, quietly = TRUE)
kfm <- kfm %>%
var_labels(
dl.milk = "Breast-milk intake (dl/day)",
sex = "Sex",
weight = "Child weight (kg)",
ml.suppl = "Milk substitute (ml/day)",
mat.weight = "Maternal weight (kg)",
mat.height = "Maternal height (cm)"
)
kfm %>%
box_plot(dl.milk ~ sex, fill = "thistle", alpha = 0.8) %>%
gf_star(x1 = 1, y1 = 10.9, x2 = 2, y2 = 11, y3 = 11.2)
kfm %>%
box_plot(dl.milk ~ sex, fill = "thistle", alpha = 0.8) %>%
gf_star(1, 10.9, 2, 11, 11.4, legend = "p = 0.035", size = 2.5)
data(energy, package = "ISwR")
energy <- energy %>%
var_labels(
expend = "Energy expenditure (MJ/day)",
stature = "Stature"
)
energy %>%
strip_error(expend ~ stature, col = "red") %>%
gf_star(1, 13, 2, 13.2, 13.4, "**")