Description Usage Arguments Details Value Warning Author(s) See Also Examples
Grouped bar plots with error bars
1 2 3 4 5 6 | bars( formula, data=NULL, heightFun=mean, errorFun=ciMean,
yLabel=NULL, xLabels=NULL, main="", ylim=NULL,
barFillColour=NULL, barLineWidth=2, barLineColour="black",
barSpaceSmall=.2, barSpaceBig=1, legendLabels=NULL,
legendDownShift=0, legendLeftShift=0, errorBarLineWidth=1,
errorBarLineColour="grey40", errorBarWhiskerWidth=.2 )
|
formula |
A two-sided formula specifying the response variable and the grouping factors |
data |
An optional data frame containing the variables |
heightFun |
The function used to calculate the bar height for a group (default=mean) |
errorFun |
The function used to calculate the error bar for a group (default=ciMean). No bars drawn if |
yLabel |
The y-axis label (defaults to the name of the response variable) |
xLabels |
The x-axis bar labels (defaults to factor labels of the appropriate grouping variable) |
main |
The plot title |
ylim |
The y-axis limit: lower bound defaults to 0, default upper bound estimated |
barFillColour |
The colours to fill the bars (defaults to a rainbow palette with saturation .3) |
barLineWidth |
The width of the bar border lines (default=2) |
barLineColour |
The colour of the bar border lines (default="black") |
barSpaceSmall |
The size of the gap between bars within a cluster, as a proportion of bar width (default=.2) |
barSpaceBig |
The size of the gap separating clusters of bars, as a proportion of bar width (default=1) |
legendLabels |
The text for the legend (defaults to factor labels of the appropriate grouping variable). No legends drawn if |
legendDownShift |
How far below the top is the legend, as proportion of plot height? (default=0) |
legendLeftShift |
How far away from the right edge is the legend, as proportion of plot? (default=0) |
errorBarLineWidth |
The line width for the error bars (default=1) |
errorBarLineColour |
The colour of the error bars (default="grey40") |
errorBarWhiskerWidth |
The width of error bar whiskers, as proportion of bar width (default=.2) |
Plots group means (or other function, if specified) broken down by one or two grouping factors. Confidence intervals (or other function) are plotted. User specifies a two sided formula of the form response ~ group1 + group2
, where response
must be numeric and group1
and group2
are factors. The group1
variable defines the primary separation on the x-axis, and the x-axis labels by default print out the levels of this factor. The group2
variable defines the finer grain separation, and the legend labels correspond to the levels of this factor. Note that group2
is optional.
Invisibly returns a data frame containing the factor levels, group means and confidence intervals.
This package is under development, and has been released only due to teaching constraints. Until this notice disappears from the help files, you should assume that everything in the package is subject to change. Backwards compatibility is NOT guaranteed. Functions may be deleted in future versions and new syntax may be inconsistent with earlier versions. For the moment at least, this package should be treated with extreme caution.
Daniel Navarro
barplot
, bargraph.CI
(in the sciplot package)
1 | # examples here...
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.