Barplot {RcmdrMisc} | R Documentation |
Bar Plots
Description
Create bar plots for one or two factors scaled by frequency or precentages.
In the case of two factors, the bars can be divided (stacked) or plotted in
parallel (side-by-side). This function is a front end to barplot
in the graphics package.
Usage
Barplot(x, by, scale = c("frequency", "percent"), conditional=TRUE,
style = c("divided", "parallel"),
col=if (missing(by)) "gray" else rainbow_hcl(length(levels(by))),
xlab = deparse(substitute(x)), legend.title = deparse(substitute(by)),
ylab = scale, main=NULL, legend.pos = "above", label.bars=FALSE, ...)
Arguments
x |
a factor (or character or logical variable). |
by |
optionally, a second factor (or character or logical variable). |
scale |
either |
conditional |
if |
style |
for two-factor plots, either |
col |
if |
xlab |
an optional character string providing a label for the horizontal axis. |
legend.title |
an optional character string providing a title for the legend. |
ylab |
an optional character string providing a label for the vertical axis. |
main |
an optional main title for the plot. |
legend.pos |
position of the legend, in a form acceptable to the |
label.bars |
if |
... |
arguments to be passed to the |
Value
Invisibly returns the horizontal coordinates of the centers of the bars.
Author(s)
John Fox jfox@mcmaster.ca
See Also
Examples
with(Mroz, {
Barplot(wc)
Barplot(wc, col="lightblue", label.bars=TRUE)
Barplot(wc, by=hc)
Barplot(wc, by=hc, scale="percent", label.bars=TRUE)
Barplot(wc, by=hc, style="parallel",
scale="percent", legend.pos="center")
})