
errorBar
function is a modified version of the S function
error.bar
. The errorBar
includes the
additional arguments draw.lower
, draw.upper
, gap.size
,
bar.ends.size
, and col
to determine whether both the lower and
upper error bars are drawn and to control the size of the gaps, the size of the bar
ends, and the color of the bars.errorBar(x, y = NULL, lower, upper, incr = TRUE, draw.lower = TRUE, draw.upper = TRUE,
bar.ends = TRUE, gap = TRUE, add = FALSE, horizontal = FALSE, gap.size = 0.75,
bar.ends.size = 1, col = 1, ..., xlab = deparse(substitute(x)), xlim, ylim)
x
.
When both x
and y
are supplied and horizontal=FALSE
(see below),
x
specifix
and y
. If incr=TRUE
, then lower
is
expected to contain the lower half widths of the error x
and y
. If incr=TRUE
, then upper
is
expected to contain the upper half widths of the error lower
and upper
represent
increments. If incr=TRUE
(the default), then lower
and upper
are
assumed to represent half the widths of thdraw.lower=TRUE
.draw.upper=TRUE
.bar.ends=TRUE
.gap=TRUE
.add=TRUE
and a graphics device is open, the error bars are added to the
plot in the open device and no axes are drawn. In this case, you should usehorizontal=TRUE
) or vertically (horizontal=FALSE
; the default).par
).errorBar
invisibly returns a list with the following components:horizontal=TRUE
) indicating the centers of the groups.errorBar
creates a plot of y
versus x
with pointwise error bars.plot
, segments
, pointwise
,
stripChart
.# The guidance document USEPA (1994b, pp. 6.22--6.25)
# contains measures of 1,2,3,4-Tetrachlorobenzene (TcCB)
# concentrations (in parts per billion) from soil samples
# at a Reference area and a Cleanup area. These data are strored
# in the data frame EPA.94b.tccb.df.
#
# Using the log-transformed data, create
#
# 1. A dynamite plot (bar plot showing mean plus 1 SE)
#
# 2. A confidence interval plot.
TcCB.mat <- summaryStats(TcCB ~ Area, data = EPA.94b.tccb.df,
se = TRUE, ci = TRUE)
Means <- TcCB.mat[, "Mean"]
SEs <- TcCB.mat[, "SE"]
LCLs <- TcCB.mat[, "95%.LCL"]
UCLs <- TcCB.mat[, "95%.UCL"]
# Dynamite Plot
#--------------
dev.new()
group.centers <- barplot(Means, col = c("red", "blue"),
ylim = range(0, Means, Means + SEs), ylab = "TcCB (ppb)",
main = "Dynamite Plot for TcCB Data")
errorBar(x = as.vector(group.centers), y = Means,
lower = SEs, draw.lower = FALSE, gap = FALSE,
col = c("red", "blue"), add = TRUE)
# Confidence Interval Plot
#-------------------------
xlim <- par("usr")[1:2]
dev.new()
errorBar(x = as.vector(group.centers), y = Means,
lower = LCLs, upper = UCLs, incr = FALSE, gap = FALSE,
col = c("red", "blue"), xlim = xlim, xaxt = "n",
xlab = "", ylab = "TcCB (ppb)",
main = "Confidence Interval Plot for TcCB Data")
axis(1, at = group.centers, labels = dimnames(TcCB.mat)[[1]])
# Clean up
#---------
rm(TcCB.mat, Means, SEs, LCLs, UCLs, group.centers, xlim)
graphics.off()
Run the code above in your browser using DataLab