Learn R Programming

mosaic (version 0.3-13)

bargraph: Create bar graphs from raw data

Description

barchart from the lattice package makes bar graphs from pre-tabulated data. Raw data can be tabulated using xtabs, but the syntax is unusual compared to the other lattice plotting functions. bargraph provides an interface that is consistent with the other lattice functions.

Usage

bargraph(x, data, groups, horizontal = FALSE, origin = 0,
    ...)

Arguments

x
a formula describing the plot
data
a data frame in which the formula x is evaluated
groups
a variable or expression used for grouping. See barchart.
horizontal
a logical indicating whether bars should be horizontal
...
additional arguments passed through to barchart
origin
beginning point for bars. For the default behavior used by barchart set origin to NULL, but 0 is a better default, and if 0 is not good, perhaps you should use a dif

Value

  • a trellis object describing the plot

See Also

link[lattice]{barchart}

Examples

Run this code
bargraph( ~ substance, data=HELPrct)
bargraph( ~ substance, data=HELPrct, horizontal=TRUE)
bargraph( ~ substance | sex, groups=homeless, data=HELPrct)

Run the code above in your browser using DataLab