Description Usage Arguments Value Author(s) Examples
Wrapper for barchart
in package lattice
. Creates a
bar chart from raw data using formula-data syntax similar to that of xtabs
,
or from a table. Defaults to a "standard"
bar chart in which the bars are vertical and un-stacked. Supports percentage bar charts.
1 2 | barchartGC(x,data=parent.frame(),type="frequency",flat=FALSE,auto.key=TRUE,
horizontal=FALSE,stack=FALSE,...)
|
x |
Either a formula or an object that can be coerced to a table. If formula, it must be of the form ~var or ~var1+var2. |
data |
Usually a data frame that supplies the variables in |
type |
Possible values are "frequency" and "percent". |
flat |
If set to TRUE, will produce bar chart that resembles the layout of |
auto.key |
Provides a simple key |
horizontal |
Determines orientation of the bars (overridden by flat) |
stack |
Determines whether bars for tallies are stacked on each other or placed next to one another (overriden by flat) |
... |
other arguments passed to |
A trellis object describing the bar chart.
Homer White hwhite0@georgetowncollege.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #bar chart of counts for one factor variable:
barchartGC(~sex,data=m111survey)
#bar chart with percentages and title:
barchartGC(~sex,data=m111survey,
type="percent",
main="Distribution of Sex")
#bar chart of counts, to study the relationship between
#two factor variables:
barchartGC(~sex+seat,data=m111survey)
#percentage bar chart, two factor variables:
barchartGC(~sex+seat,data=m111survey,type="percent")
#From tabulated data:
sexseat <- xtabs(~sex+seat,data=m111survey)
barchartGC(sexseat,type="percent",main="Sex and Seating Preference")
#from tabulated data:
dieTosses <- c(one=8,two=18,three=11,four=7,five=9,six=7)
barchartGC(dieTosses,main="60 Rolls of a Die")
# a "flat" bar chart, pictorial version of xtabs()
barchartGC(~sex+seat,data=m111survey,flat=TRUE,ylab="Sex")
# a "flat" bar chart, pictorial version of xtabs()
barchartGC(~sex+seat,data=m111survey,type="percent",flat=TRUE,ylab="Sex")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.