Learn R Programming

vcd (version 0.1-3.5)

sieveplot: Sieve Plots

Description

Visualization of two-way contingency tables: plots rectangles with surfaces proportional to the expected cell frequencies and filled with a number of squares equal to the expected frequencies. Thus, the densities visualize the deviations of the observed from the expected values.

Usage

## S3 method for class 'default':
sieveplot(x, reverse.y = TRUE,
          type = c("sieve", "expected"), main = NULL,
          values = c("none", "cells", "margins", "both"),
          frequencies = c("absolute", "relative"),
          sieve.colors = c("red","blue"),
          sieve.lty = c("longdash", "solid"),
          exp.color = "gray", exp.lty = "dotted",
          margin = 0.01, cex.main = 2, cex.lab = 1.5,
          xlab = names(dimnames(x))[2],
          ylab = names(dimnames(x))[1], ...)
## S3 method for class 'formula':
sieveplot(formula, data = NULL, ..., subset)

Arguments

x
a two-way contingency table, as generated by table.
reverse.y
if TRUE, the y axis is reversed (i.e., the rectangles' positions correspond to the contingency table).
type
expected fills the rectangles according to the expected frequencies.
main
user specified title.
values
optionally, the frequencies of the cells or margins or of both can be plotted.
frequencies
chooses the type of these frequencies: relative or absolute.
sieve.colors, sieve.lty
vectors with up to two color/line type entries: the first is used for negative and the second for positive deviations from the expected frequencies.
exp.color, exp.lty
color/line type entry for the expected values grid.
margin
lines of margin between the cell rectangles.
cex.main
font size of title.
cex.lab
font size of labels.
xlab, ylab
labels of x- and y-axis.
formula
a formula, such as y ~ x. For details, see xtabs.
data
a data.frame (or list), or a contingency table from which the variables in `formula' should be taken.
subset
an optional vector specifying a subset of observations to be used for plotting.
...
further graphics parameters (see par).

References

H. Riedwyl & M. Sch�pbach (1994), Parquet diagram to plot contingency tables. In F. Faulbaum (ed.), Softstat '93: Advances in Statistical Software, 293-299. Gustav Fischer, New York.

M. Friendly (2000), Visualizing Categorical Data, SAS Institute, Cary, NC.

See Also

mosaicplot

Examples

Run this code
data(HairEyeColor)

## aggregate over `sex':
(tab <- margin.table(HairEyeColor, c(2,1)))

## plot expected values:
sieveplot(tab, type = "expected", values = "both")

## plot sieve diagram:
sieveplot(tab)

## an example for the formula interface:
data(VisualAcuity)
sieveplot(Freq ~ right + left,  data = VisualAcuity, reverse.y = FALSE)

Run the code above in your browser using DataLab