stripChart
is a modification of the Rfunction stripchart
.
It is a generic function used to produce one dimensional scatter
plots (or dot plots) of the given data, along with text indicating sample size and
estimates of location (mean or median) and scale (standard deviation
or interquartile range), as well as confidence intervals for the population
location parameter.
One dimensional scatterplots are a good alternative to boxplots
when sample sizes are small or moderate. The function invokes particular
methods
which depend on the class
of the first argument.stripChart(x, ...)
## S3 method for class 'formula':
stripChart(x, data = NULL, dlab = NULL,
subset, na.action = NULL, ...)
## S3 method for class 'default':
stripChart(x, method = "stack", seed = 47,
jitter = 0.1 * cex, offset = 1/2, vertical = TRUE, group.names,
group.names.cex = cex, drop.unused.levels = TRUE, add = FALSE,
at = NULL, xlim = NULL, ylim = NULL, ylab = NULL, xlab = NULL,
dlab = "", glab = "", log = "", pch = 1, col = par("fg"),
cex = par("cex"), points.cex = cex, axes = TRUE, frame.plot = axes,
show.ci = TRUE, location.pch = 16, location.cex = cex,
conf.level = 0.95, min.n.for.ci = 2,
ci.offset = 3/ifelse(n > 2, (n-1)^(1/3), 1),
ci.bar.ends = TRUE, ci.bar.ends.size = 0.5 * cex,
ci.bar.gap = FALSE, n.text = "bottom",
n.text.line = ifelse(n.text == "bottom", 2, 0),
n.text.cex = cex, location.scale.text = "top",
location.scale.digits = 1, location.scale.text.line =
ifelse(location.scale.text == "top", 0, 3.5),
location.scale.text.cex =
cex * 0.8 * ifelse(n > 6, max(0.4, 1 - (n-6) * 0.06), 1),
p.value = FALSE, p.value.digits = 3, p.value.line = 2,
p.value.cex = cex, group.difference.ci = p.value,
group.difference.conf.level = 0.95,
group.difference.digits = location.scale.digits,
ci.and.test = "parametric", ci.arg.list = NULL,
test.arg.list = NULL, alternative = "two.sided", ...)
x
should be taken.NA
s. The default is to ignore missing values in either the response or
the group."overplot"
causes such points to be overplotted, but it is also possible to specify
"jitter"
to jitter the points, or "stack"
to
have coincmethod="jitter"
is used, the argument seed
is passed to
the Rfunction set.seed
. Since jittering depends on the
Rrandom number generator, using the same value of method="jitter"
is used, jitter
gives the amount of jittering applied.vertical=TRUE
(the default), the plots are drawn vertically rather than horizontally.plot.default
).
The default is the current value of the graphics pdrop.unused.levels=TRUE
, groups with no observations are dropped.add=TRUE
; defaults to 1:n
where n
is the number of groups.plot.window
.title
.dlab
and glab
labels may be used
instead of xlab
and ylab
if those are not specified. dlab
applies
to the continuous data axis (the $y$-axplot.default
.par
.cex
value for the points plotted.plot.default
.show.ci=TRUE
.plot.default
).
The default is location.pch=
plot.default
conf.level=0.95
.min.n.for.ci=2
.n
) in units of
cex
indicating the amount of space between the line showing the confidence interval
and tick mark associated with a particular group. The dci.bar.ends=TRUE
.cxy
indicating the size of confidence interval
bar ends. The default value is half of the current value of cex
.ci.bar.gap=FALSE
."bottom"
(the default), "top"
, and "none"
.n.text.line=2
when n.text="bottom"
and 0
otherwise.plot.default
). The default is the curr"top"
(the default), "bottom"
location.scale.digits=1
.location.scale.text.line=0
when n.text="top"
and 3.5
otherwise.plot.default
). p.value=TRUE
.
The p-value is displayed at the top of the graph.p.value.digits=3
.p.value.line=2
.plot.default
p.value
argument. The confidence interval is conf.level=0.95
.group.difference.digits=location.sca
ci.and.test="nonparametric"
) methods.
When ci.and.test="parametric"
(the default), confidence intervals fci.arg.list=NULL
.test.arg.list=NULL
. In particular, in the case when there are two groups,
ci.and.test="parametric"
"two.sided"
(the default),
"less"
, and "greater"
.stripChart
invisibly returns a list with the following components:vertical=FALSE
) indicating the centers of the groups.p.value=TRUE
, the list also includes these
components:stripchart
, t.test
, wilcox.test
,
aov
, kruskal.test
, t.test
.# 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.
#
# First create one-dimensional scatterplots to compare the
# TcCB concentrations between the areas and use a nonparametric
# test to test for a difference between areas.
dev.new()
stripChart(TcCB ~ Area, data = EPA.94b.tccb.df,
p.value = TRUE, ci.and.test = "nonparametric",
ylab = "TcCB (ppb)")
#----------
# Now log-transform the TcCB data and use a parametric test
# to compare the areas.
dev.new()
stripChart(log10(TcCB) ~ Area, data = EPA.94b.tccb.df,
p.value = TRUE, ci.and.test = "parametric",
ylab = "log10 [ TcCB (ppb) ]")
#----------
# Repeat the above procedure, but allow the variances to differ.
dev.new()
stripChart(log10(TcCB) ~ Area, data = EPA.94b.tccb.df,
p.value = TRUE, ci.and.test = "parametric",
ylab = "log10 [ TcCB (ppb) ]",
test.arg.list = list(var.equal = FALSE))
#----------
# Repeat the above procedure, but jitter the points instead of
# stacking them.
dev.new()
stripChart(log10(TcCB) ~ Area, data = EPA.94b.tccb.df,
p.value = TRUE, ci.and.test = "parametric",
ylab = "log10 [ TcCB (ppb) ]",
test.arg.list = list(var.equal = FALSE),
method = "jitter", ci.offset = 4)
#==========
# Clean up
#---------
graphics.off()
Run the code above in your browser using DataLab