textTable.tabular {tablesgg} | R Documentation |
Create a texttable
from a tabular
Object
Description
Convert a tabular
object, representing a 2D data summary table,
into a textTable
object, which can be plotted.
Usage
## S3 method for class 'tabular'
textTable(x, title=character(0), subtitle=character(0),
foot=character(0), rowheadLabels=TRUE, ...)
Arguments
x |
An object of class |
title , subtitle , foot |
Optional character vectors providing annotation for the table. May be
empty (i.e., |
rowheadLabels |
Character vector or logical scalar specifying labels for the row header
columns of the table. FALSE or |
... |
Additional arguments passed to |
Details
tabular
objects are produced by the tabular
function in
package tables
. This function converts them to textTable
objects to enable plotting. It can also add table annotation.
Row headers and column headers are derived from the rowLabels
and
colLabels
attributes of x
, respectively. It appears that
tabular
objects always have "rowLabels", "colLabels" and a body
with non-zero dimensions (although this is not required for
textTable
objects in general). In addition, runs of duplicated
values in rowLabels
and colLabels
are replaced by NA; the
NAs are changed back to the original values by this function. The
dropcells
attribute is a character matrix matching the table body.
If not NA, the value in dropcells
is used to replace the cell
content after formatting.
In the returned object, components body
, rowhead
, and
colhead
will each have an attribute type
. For body
the attribute is a character matrix containing a string describing the
type of value represented in each cell of the table body; namely, the
first element of the vector returned by function class()
as applied
to each element of x
. For rowhead
and colhead
,
type
is a character vector with one element per header variable
(i.e., per column of rowhead
or row of colhead
). Since
tabular
objects do not retain the classes of the variables that
define row and column dimensions of a table, type
will be set to
NA.
Components of the returned object will also have an attribute
justification
. It will be a character matrix or vector of the same
size and shape as the component; a value of NA means that the type of
justification is not specified. Values for the table body and row and
column headers will be taken from x
. Values for table annotation
will be NA.
Value
An object with S3 class textTable
. See the documentation for the
generic function for a description of the structure of this object.
See Also
tables::tabular
, tables::format.tabular
,
plot.textTable
Examples
# 'iris2_tab' is a 'tabular' object created using 'tables::tabular'.
class(iris2_tab)
# 'tables' package provides a 'print' method for such objects:
if (requireNamespace("tables", quietly=TRUE)) {
print(iris2_tab)
}
# This package provides 'textTable' and 'plot' methods for such objects:
ttbl <- textTable(iris2_tab)
plot(ttbl)
# ... or just
#plot(iris2_tab) # same