bpCI | R Documentation |
Add confidence intervals (error bars) and group comparisons to barplots.
bpCI(
x,
horiz = FALSE,
ci = TRUE,
ci.u,
ci.l,
ci.width = 0.5,
sig = FALSE,
pvals,
pch = "*",
show.p = FALSE,
...
)
x |
the return value of |
horiz |
logical; if |
ci |
logical; draw error bars (must give |
ci.u, ci.l |
a numeric vector or matrix having the same dimensions as
|
ci.width |
width of the ends of the error bars, will depend on
|
sig |
logical; if |
pvals |
p-values of group comparisons to be displayed as sig stars |
pch |
plotting character to be used for significance; default is
|
show.p |
logical; if |
... |
additional graphical parameters passed to |
## generate data and p-values
hh <- t(VADeaths)[1:2, 5:1]
ci.l <- hh * 0.85
ci.u <- hh * 1.15
pvals <- pt(apply(hh, 2, diff), 1) / 5:1
bp <- barplot(hh, beside = TRUE, ylim = c(0, 100))
bpCI(bp, ci.u = ci.u, ci.l = ci.l, sig = TRUE, pvals = pvals)
bpCI(bp, ci.u = ci.u, ci.l = ci.l, sig = TRUE, pvals = pvals,
show.p = TRUE, pch = FALSE)
mtext("Signif. codes: 0 '+++' 0.001 '++' 0.01 '+' 0.05 '.' 0.1 ' ' 1",
side = 1, at = par('usr')[2], line = 2, adj = 1, cex = .8, font = 3)
bp <- barplot(hh <- cbind(x = c(465, 91) / 465 * 100,
y = c(200, 840) / 840 * 100,
z = c(37, 17) / 37 * 100),
beside = TRUE, width = c(465, 840, 37),
col = c(1, 2), ylim = c(0,130))
ci.l <- hh * 0.85
ci.u <- hh * 1.15
pv <- pt(-abs(apply(hh, 2, diff)), 1)
bpCI(bp, ci.u = ci.u, ci.l = ci.l, sig = TRUE, pvals = pv, ci.width = 100,
col = 'red', lty = 'dashed', lwd = 2)
mtext("Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1",
side = 1, at = par('usr')[2], line = 2, adj = 1, cex = .8, font = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.