| barchart.table {lattice} | R Documentation |
Contingency tables are often displayed using barcharts and dotplots. These methods are provided for convenience and operate directly on tables. Arrays and matrices are simply coerced to be a table.
## S3 method for class 'table':
barchart(x, data, groups = TRUE,
origin = 0, stack = TRUE, ..., horizontal = TRUE)
## S3 method for class 'array':
barchart(x, data, ...)
## S3 method for class 'matrix':
barchart(x, data, ...)
## S3 method for class 'table':
dotplot(x, data, groups = TRUE, ..., horizontal = TRUE)
## S3 method for class 'array':
dotplot(x, data, ...)
## S3 method for class 'matrix':
dotplot(x, data, ...)
x |
a table, array or matrix object.
|
data |
should not be specified. If specified, will be ignored with a warning. |
groups |
logical, whether to use the last dimension as the grouping variable in the display. |
origin, stack |
arguments to panel.barchart controlling the display. The
defaults for the table method are different.
|
horizontal |
logical, indicating whether the plot should be horizontal (with the categorical variable on the y-axis) or vertical. |
... |
other arguments, passed to the underlying formula
method.
|
The first dimension is used as the variable on the vertical axis. The
last dimension is optionally used as a grouping variable (to produce
stacked barcharts by default). All other dimensions are used as
conditioning variables. The order of these variables cannot be
altered (except by permuting the original argument using
t or aperm). For more flexibility, use
the formula method after converting the table to a data frame using
the relevant as.data.frame
method.
An object of class "trellis". The
update method can be used to
update components of the object and the
print method (usually called by
default) will plot it on an appropriate plotting device.
Deepayan Sarkar
barchart, t, aperm,
table, panel.barchart,
Lattice
barchart.table, barchart.array, barchart.matrix, dotplot.table, dotplot.array, dotplot.matrix
hplot
barchart(Titanic, scales = list(x = "free"),
auto.key = list(title = "Survived"))
R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(lattice)
> png(filename="images/barchart.table_%03d.png" ,width=480, height=480)
> ### Name: barchart.table
> ### Title: table methods for barchart and dotplot
> ### Aliases: barchart.table barchart.array barchart.matrix dotplot.table
> ### dotplot.array dotplot.matrix
> ### Keywords: hplot
>
> ### ** Examples
>
> barchart(Titanic, scales = list(x = "free"),
+ auto.key = list(title = "Survived"))
>
>
>
> dev.off()
null device
1
>