Learn R Programming

tablesgg (version 0.9-1)

textTable.ftable: Create a texttable from an ftable

Description

Create a textTable object representing a flattened multiway contingency table.

Usage

# S3 method for ftable
textTable(x, colheadLabels=c("layers", "none", "paste"), sep=": ", 
    title=character(0), subtitle=character(0), foot=character(0), ...)

Value

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

Arguments

x

An ftable object, as produced by R's ftable function, representing a flattened 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).

...

Ignored, with a warning. (Included for compatibility with the generic.)

See Also

ftable, format.ftable

Examples

Run this code
# From examples in '?ftable':
data(Titanic, package="datasets")
ft <- ftable(Titanic, row.vars = 1:2, col.vars = "Survived")
ttbl <- textTable(ft, title="Plotting an 'ftable'")
plot(ttbl)

data(mtcars, package="datasets")
ft <- ftable(mtcars$cyl, mtcars$vs, mtcars$am, mtcars$gear, row.vars = c(2, 4),
             dnn = c("Cylinders", "V/S", "Transmission", "Gears"))
ttbl <- textTable(ft, colheadLabels="none")
plt1 <- plot(ttbl, title="Plotting an 'ftable'", 
             subtitle="No colheadLabels")
ttbl <- textTable(ft, colheadLabels="layers")
plt2 <- plot(ttbl, title="Plotting an 'ftable'", 
             subtitle="colheadLabels = 'layers'")
ttbl <- textTable(ft, colheadLabels="paste")
plt3 <- plot(ttbl, title="Plotting an 'ftable'", 
             subtitle="colheadLabels = 'paste'")
print(plt1, position=c("left", "top"))
print(plt2, position=c("left", "center"), newpage=FALSE)
print(plt3, position=c("left", "bottom"), newpage=FALSE)
  

Run the code above in your browser using DataLab