sieve | R Documentation |
(Extended) sieve displays for n-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.
## Default S3 method:
sieve(x, condvars = NULL, gp = NULL, shade = NULL,
legend = FALSE, split_vertical = NULL, direction = NULL, spacing = NULL,
spacing_args = list(), sievetype = c("observed","expected"),
gp_tile = gpar(), scale = 1, main = NULL, sub = NULL, ...)
## S3 method for class 'formula'
sieve(formula, data, ..., main = NULL, sub = NULL, subset = NULL)
x |
a contingency table in array form, with optional category
labels specified in the |
condvars |
vector of integers or character strings indicating conditioning variables, if any. The table will be permuted to order them first. |
formula |
a formula specifying the variables used to create a
contingency table from |
data |
either a data frame, or an object of class |
subset |
an optional vector specifying a subset of observations to be used. |
shade |
logical specifying whether |
sievetype |
logical indicating whether rectangles should be filled
according to |
gp |
object of class |
gp_tile |
object of class |
scale |
scaling factor for the sieve. |
legend |
either a legend-generating function, a legend
function (see details of |
split_vertical |
vector of logicals of length |
direction |
character vector of length |
spacing |
spacing object, spacing function, or corresponding
generating function (see |
spacing_args |
list of arguments for the generating function, if
specified (see |
main , sub |
either a logical, or a character string used for plotting
the main (sub) title. If logical and |
... |
Other arguments passed to |
sieve
is a generic function which currently has a default method and a
formula interface. Both are high-level interfaces to the
strucplot
function, and produce (extended) sieve
displays. Most of the functionality is described there, such as
specification of the independence model, labeling, legend, spacing,
shading, and other graphical parameters.
The layout is very flexible: the specification of shading, labeling,
spacing, and legend is modularized (see strucplot
for
details).
The "structable"
visualized is returned invisibly.
To be faithful to the original definition by Riedwyl & Schüpbach, the default is to have no spacing between the tiles for two-way tables.
David Meyer David.Meyer@R-project.org
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.
Meyer, D., Zeileis, A., and Hornik, K. (2006),
The strucplot framework: Visualizing multi-way contingency tables with
vcd.
Journal of Statistical Software, 17(3), 1-48.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v017.i03")} and available as
vignette("strucplot")
.
assoc
,
strucplot
,
mosaic
,
structable
,
doubledecker
data("HairEyeColor")
## aggregate over 'sex':
(haireye <- margin.table(HairEyeColor, c(2,1)))
## plot expected values:
sieve(haireye, sievetype = "expected", shade = TRUE)
## plot observed table:
sieve(haireye, shade = TRUE)
## plot complete diagram:
sieve(HairEyeColor, shade = TRUE)
## example with observed values in the cells:
sieve(haireye, shade = TRUE, labeling = labeling_values,
gp_text = gpar(fontface = 2))
## example with expected values in the cells:
sieve(haireye, shade = TRUE, labeling = labeling_values,
value_type = "expected", gp_text = gpar(fontface = 2))
## an example for the formula interface:
data("VisualAcuity")
sieve(Freq ~ right + left, data = VisualAcuity)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.