labeling_cells_list {vcd} | R Documentation |
Labeling Functions for Strucplots
Description
These functions generate labeling functions that produce labels for strucplots.
Usage
labeling_cells(labels = TRUE, varnames = TRUE,
abbreviate_labels = FALSE, abbreviate_varnames = FALSE,
gp_text = gpar(), lsep = ": ", lcollapse = "\n",
just = "center", pos = "center", rot = 0,
margin = unit(0.5, "lines"), clip_cells = TRUE,
text = NULL, ...)
labeling_list(gp_text = gpar(), just = "left", pos = "left", lsep = ": ",
sep = " ", offset = unit(c(2, 2), "lines"),
varnames = TRUE, cols = 2, ...)
Arguments
labels |
vector of logicals indicating, for each dimension, whether labels for the factor levels should be drawn or not. Values are recycled as needed. |
varnames |
vector of logicals indicating, for each dimension, whether variable names should be drawn. Values are recycled as needed. |
abbreviate_labels |
vector of integers or logicals indicating,
for each dimension, the number of characters the labels should be
abbreviated to.
|
abbreviate_varnames |
vector of integers or logicals indicating,
for each dimension, the number of characters the variable
(i.e., dimension) names should be abbreviated to.
|
gp_text |
object of class |
lsep |
character that separates variable names from the factor levels. |
sep |
character that separates the factor levels (only used for
|
offset |
object of class |
cols |
number of text columns (only used for
|
lcollapse |
character that separates several variable name/factor
level-combinations. Typically a line break.
(Only used for |
just , pos |
character string of length 1 ( |
rot |
rotation angle in degrees, used for all labels (only used
for |
margin |
object of class |
clip_cells |
logical indicating whether text should be clipped at
the cell borders (only used for |
text |
Optionally, a character table of the same dimensions than
the contingency table whose entries will then be used instead of
the labels. |
... |
Currently not used. |
Details
These functions generate labeling functions that can add different
kinds of labels to an existing plot. Typically they are
supplied to strucplot
which then generates and calls
the labeling function. They assume that a strucplot has been drawn
and the corresponding viewport structure is pushed, so that by
navigating through the viewport tree the labels can be positioned
appropriately.
This help page only documents labeling_list
and
labeling_cells
; more functions are described on the help page
for labeling_border
.
The functions can also be used ‘stand-alone’ as shown in the examples.
Using labeling_list
will typically necessitate a bottom margin
adjustment.
Value
A function with arguments:
d |
|
split_vertical |
vector of logicals indicating the split directions. |
condvars |
integer vector of conditioning dimensions |
Author(s)
David Meyer David.Meyer@R-project.org
References
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.
doi:10.18637/jss.v017.i03 and available as
vignette("strucplot")
.
See Also
labeling_border
,
structable
,
grid.text
Examples
data("Titanic")
mosaic(Titanic, labeling = labeling_cells)
mosaic(Titanic, labeling = labeling_list)
## A more complex example, adding the observed frequencies
## to a mosaic plot:
tab <- ifelse(Titanic < 6, NA, Titanic)
mosaic(Titanic, pop = FALSE)
labeling_cells(text = tab, margin = 0)(Titanic)