textTable.table: Create a 'texttable' from a 'table' or 'xtabs' Object

Description Usage Arguments Details Value See Also Examples

View source: R/textTable_methods.bare.R

Description

Create a textTable object representing a flattened multiway contingency table.

Usage

1
2
3
## S3 method for class 'table'
textTable(x, colheadLabels=c("layers", "none", "paste"), sep=": ", 
    title=character(0), subtitle=character(0), foot=character(0), ...)

Arguments

x

A table object, as produced by R's table or xtabs functions, representing a multiway contingency table.

colheadLabels

Character scalar; how to display names of column header variables. "none" means to not display them. "layers" (the default) means to display them as additional column header layers (so each header variable occupies two rows instead of one). "paste" means to paste the variable name in front of each of its values, separated by sep.

sep

Character scalar; string that separates a variable name from its values when colheadLabels is "paste".

title, subtitle, foot

Optional character vectors providing annotation for the table. May be empty (i.e., character(0), the default).

...

Additional arguments passed to ftable, to convert x to an ftable object.

Details

This function simply converts x to an ftable (flattened multiway contingency table), then applies the corresponding textTable method to that object.

It also works for xtabs objects since they inherit from table.

Value

An object with S3 class textTable. See the documentation for the generic for details about its structure.

See Also

ftable, xtabs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# UCBAdmissions is a contingency table in array form ('table' object).
data(UCBAdmissions, package="datasets")
ttbl <- textTable(UCBAdmissions)
plot(ttbl, title=c("Plotting a 'table' object:", "UCB Admissions data"))

# Method also works for 'xtabs' since they inherit from 'table' (example 
# from '?xtabs'):
data(warpbreaks, package="datasets")
warpbreaks$replicate <- rep_len(1:9, 54)
xt <- xtabs(breaks ~ wool + tension + replicate, data = warpbreaks)
ttbl <- textTable(xt, title="Plotting an 'xtabs' object (warpbreaks data)")
plot(ttbl)
  

tablesgg documentation built on June 3, 2021, 1:06 a.m.