groupedBar | R Documentation |
Create a bar chart of a single categorical variable or a grouped bar chart of two categorical variables.
groupedBar(resp, ...)
## Default S3 method:
groupedBar(
resp,
condvar = NULL,
percent = TRUE,
print = TRUE,
cond.name = deparse(substitute(condvar)),
resp.name = deparse(substitute(resp)),
...
)
## S3 method for class 'formula'
groupedBar(formula, data = parent.frame(), subset, ...)
resp |
a factor variable. If |
... |
further arguments to be passed to or from methods. |
condvar |
a factor variable to condition on. If |
percent |
a logical value. Should the y-axis give percent or counts? |
print |
a logical value. If |
cond.name |
Label for variable |
resp.name |
Label for variable |
formula |
a formula of the form |
data |
a data frame that contains the variables in the formula. |
subset |
an optional vector specifying a subset of observations to be used. |
For a single factor variable, a bar plot. If two factor variables are given,
then a bar plot of x
conditioned by condvar
. This command
uses R's table
command so missing values are automatically removed.
Returns invisibly a table of the variable(s).
groupedBar(default)
: Grouped bar chart
groupedBar(formula)
: Grouped bar chart
Laura Chihara
groupedBar(states03$Region)
## Not run:
groupedBar(states03$DeathPenalty, states03$Region, legend.loc = "topleft")
#Using a formula syntax:
groupedBar(~Region, data = states03)
groupedBar(DeathPenalty ~ Region, data = states03, legend.loc = "topleft")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.