panel.bwstrip {agsemisc} | R Documentation |
Box plots with added stripplots, densityplots, mean/stderr marker etc.
panel.bwstrip(x, y, groups, subscripts, pch, col, box.ratio = 5, varwidth = FALSE, whiskerpos = 0.1, logbase, type="mean,mad,strip,N,grid", densityplot=expression(density(X,cut=2)), strip.limit=100, seplines = NULL, N.label = "N=% \n", extend = TRUE, levels.fos = NULL, ...)
x |
the data, as in panel.bwplot |
y |
the number of the box, as in panel.bwplot |
groups |
a factor indicating a partitioning of the data x . Relevant for
the pch and col arguments. |
subscripts |
Argument internally used by Lattice to realize the
groups functionality. |
pch |
A integer vector, character vector or list that indicates the value
to be used as pch (plot character) for the stripplot for each level of
groups .
You will need a list if you want to mix plot symbols (indicated by
integers) with plot characters (indicated by characters).
There is a simpler method to specify any of these cases, namely a
single string with entries separated by commas. One-digit numeric
entries will evaluate to a plot character, two-digit numeric entries
will evaluate to an integer plot symbol.
For instance, "1,w,13,2,02" will evaluate into
list("1", "w", 13, "2", 2) .
Defaults to all trellis.par.get("superpose.symbol")$pch .
Note that with groups=gg you can often use
pch=levels(gg) , because Lattice will ignore all but the first
character of a string. |
col |
Analogous to pch, but indicating color.
Integers indicate color numbers, strings indicate color names, both
can be mixed in the comma-separated string format.
Defaults to all trellis.par.get("superpose.symbol")$col . |
box.ratio |
Like in panel.bwplot, but the different default value withstands the call default of 1 that is imposed by Lattice (as of R 2.2). |
varwidth |
vary box thickness according to number of data values,
as in panel.bwplot |
whiskerpos |
With large values in the range 1..Inf, whiskerpos is equivalent
to the coef argument to panel.bwplot (or really
boxplot.stats ), i.e. each whisker is at the farthest data
value that is at most whiskerpos times the interquartile range
(or box width) away from the box. Only the values 1.5, 2 or 3 are common.
In contrast, with small values w in the range 0..0.25, the
whiskers will indicate the fixed quantiles w and 1-w .
This is easier to explain to non-statisticians and often more
appropriate for larger samples.
So whiskerpos==0 will produce whiskers at the min and max of the
data, the default will indicate the 10-percentile and the 90-percentile,
and whiskerpos==0.25 makes the whiskers disappear. |
logbase |
An argument logbase=b indicates that
the high-level plot is using a log scale axis to base b and hence
the data is logarithmic rather than real and needs to be converted back
before computing mean, interpolating quantiles etc. |
type |
Declares which boxplot elements to include in the plot. Is either a
comma-separated string of element names (as shown in the default) or a
vector of such names.
The elements have the following meaning:
mean plots something like –M– indicating the mean and its
standard error.
mad will indicate the stderror of the median (median absolute
deviation, as computed by mad divided by sqrt(n))
as a line left and right of the median dot.
strip will produce a stripplot of the individual data points,
scattered vertically to make similar values more visible.
density will add a densityplot and a support line (extending
along the range of the data). The plot can be customized via the
densityplot argument.
N will indicate the number of datapoints according to the
N.label argument.
grid will draw dotted vertical lines aligned with x-axis labels.
Elements not mentioned will be left out of the plot.
The box and median dot are always included (this
is a boxplot, after all), the whiskers can be suppressed by
whiskerpos=0.25 . |
densityplot |
Relevant if "density" is mentioned in the type
argument. Must be an expression describing a call to
density that concerns the data vector X (an
uppercase x!), which will be the data for the current boxplot for each
evaluation of the expression.
If a densityplot appears, the boxplot will not be color-filled. |
strip.limit |
If T , will reduce the stripplot to only the outliers, i.e., the
values beyond the whiskers.
If an integer, will suppress the stripplot entirely if there are more
than this many values in the current boxplot. |
seplines |
A vector of vertical positions where horizontal lines will be drawn to separate the boxplots into groups. Position 1.5, 2.5 etc. is above the lowest, second-lowest boxplot etc. |
N.label |
A string such as "
number of values underlying the boxplot and the resulting string is
printed at the right of the plot iff N is mentioned in the
type argument.
Use trailing blanks and newlines to adjust positioning. |
extend |
If TRUE, will print to console some statistics for each sample:
the quantiles (0, 0.25, 0.5, 0.75,, 1), mean, quartile ratio (or at least
interquartile range) and the number of data points.
If extend is a function, it will be called with four arguments:
data vector x, current y, groups, subscripts. |
levels.fos |
weird stuff, but means the same as in panel.bwplot |
... |
all other arguments will be ignored. |
A lattice panel function to be used with bwplot.
Can draw a boxplot plus stripplot plus densityplot, indicate groups,
mark the mean and its stderror, report N, and more.
Graphical parameters are controlled by the trellis.par.set
parameters
box.rectangle, box.umbrella, superpose.symbol
(which is
non-standard), and reference.line
.
The horizontal=F
option available in panel.bwplot
is not
supported here.
Lutz Prechelt prechelt@inf.fu-berlin.de
a.resetplotparams
,
plotf
,
panel.xy
.
# set grid.prompt(TRUE) to see each plot separately (click graphics window) data(iris) a.resetplotparams() print(bwplot(Species~Sepal.Length, data=iris, panel=panel.bwstrip)) # A plot including a density plot: print(bwplot(Species~Sepal.Length, data=iris, panel=panel.bwstrip, type="mean,strip,density")) # A customized plot: print(bwplot(~Sepal.Length, data=iris, panel=panel.bwstrip, groups=Species, pch=levels(iris$Species), strip.limit=200, type="mean,strip,density", densityplot=expression(density(X, cut=1)))) # A conventional-style plot: print(bwplot(Species~Sepal.Length, data=iris, panel=panel.bwstrip, type="mean,strip,grid", strip.limit=TRUE, whiskerpos=1.5, densityplot=expression(density(X, cut=1)))) # A plot showing some other features: print(bwplot(cut(Sepal.Width,4)~Sepal.Length, data=iris, panel=panel.bwstrip, groups=Species, varwidth=TRUE, box.ratio=20, which="strip,N", strip.limit=50, pch="1,2,3"))