Barplot {RcmdrMisc} | R Documentation |
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.
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", ...)
x |
a factor. |
by |
optionally, a second factor. |
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 |
... |
arguments to be passed to the |
Returns NULL
invisibly.
John Fox jfox@mcmaster.ca
if (require(car)){ data(Mroz) with(Mroz, { Barplot(wc) Barplot(wc, col="lightblue") Barplot(wc, by=hc) Barplot(wc, by=hc, scale="percent") Barplot(wc, by=hc, style="parallel", scale="percent", legend.pos="center") }) }