sieveplot {vcd}R Documentation

Sieve Plots

Description

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

Usage

## Default S3 method:
sieveplot(x, reverse_y = TRUE, type = c("observed", "expected"),
  main = deparse(substitute(x)),
  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, newpage = TRUE, pop = TRUE,
  margins = c(4,3,4,4), 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 logical; if TRUE, the y axis is reversed (i.e., the rectangles' positions correspond to the contingency table).
type switch indicating whether rectangles should be filled according to observed or expected frequencies.
main character string specifying the title.
values switch indicating whether the frequencies of cells or margins or of both should be plotted.
frequencies switch indicating 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.
margins vector of margins (see par).
newpage logical; if TRUE, the plot is drawn on a new page.
pop logical; if TRUE, all newly generated viewports are popped after plotting.
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 the rows in the data frame to be used for plotting.
... further graphics parameters (see gpar).

Author(s)

David Meyer David.Meyer@R-project.org

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

mosaic

Examples

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)

[Package vcd version 0.9-0 Index]