| toLatex-ftable {simsalapar} | R Documentation |
Convert Flat Contingency Table (ftable) and VarLists to LaTeX Table
Description
The ftable method of toLatex() converts
an ftable to a LaTeX table via tablines().
Analogously, the varlist method of
toLatex() converts an varlist to a LaTeX table.
fftable() essentially calls format.ftable() and adds
attributes ncv and nrv to the return object.
tablines() computes ingredients for converting a
character matrix with attributes to a
LaTeX table.
cattablines() is a small auxiliary function which creates rows
of a LaTeX table from a given matrix.
Usage
## S3 method for class 'ftable'
toLatex(object, vList = NULL,
x.escape = FALSE, exprFUN = expr2latex, escapeFUN = escapeLatex,
align = NULL, booktabs = TRUE, head = NULL,
rsep = "\\\\", sp = if(booktabs) 3 else 1.25, rsep.sp = NULL,
csep = " & ", quote = FALSE, lsep=" \\textbar\\ ",
do.table = TRUE, placement = "htbp", center = TRUE,
fontsize = "normalsize", caption = NULL, label = NULL, ...)
## S3 method for class 'varlist'
toLatex(object,
col.vars = c("Variable", "expression", "type", "value"),
exprFUN = expr2latex, escapeFUN = escapeLatex,
align = NULL, booktabs = TRUE, head = NULL,
rsep = "\\\\", sp = if(booktabs) 3 else 1.25, rsep.sp = NULL, csep = " & ",
do.table = TRUE, placement = "htbp", center = TRUE,
fontsize = "normalsize", caption = NULL, label = NULL, ...)
fftable(x, lsep = " | ", quote = FALSE, method = "compact", ...)
tablines(x, align = NULL, booktabs = TRUE, head = NULL,
rsep = "\\\\", sp = if(booktabs) 3 else 1.25, rsep.sp = NULL,
csep = " & ", quote = FALSE)
cattablines(x, rsep = "\\\\", csep = " & ", include.rownames = TRUE)
Arguments
object |
an |
x |
for |
vList |
a variable specification list see |
x.escape |
logical indicating if the “body” entries of the
table should be escaped by |
exprFUN |
a function, by default |
escapeFUN |
a function, by default |
align |
either a |
booktabs |
|
head |
either |
rsep |
|
sp |
|
rsep.sp |
|
csep |
|
quote, lsep, method |
see |
col.vars |
character vector of length 3 or 4 ( |
do.table |
|
placement |
(if |
center |
|
fontsize |
|
caption |
(if |
label |
(if |
include.rownames |
|
... |
additional arguments passed to |
Value
toLatex() returns an object as from wrapLaTable().
fftable() returns a formatted flat contingency table as
returned by format.ftable() with added attributes ncv
(number of column variables) and nrv (number of row variables).
tablines() a list with components
body |
|
body.raw |
|
head |
|
head.raw |
|
align |
alignment string. |
rsepcol |
|
cattablines() outputs the formatted lines for copy-and-paste
into a LaTeX table.
Author(s)
Marius Hofert and Martin Maechler.
References
see simsalapar-package.
See Also
wrapLaTable() for how to wrap the lines of a LaTeX table
created by tablines() in a LaTeX table and tabular environment.
Examples
## Different table layouts for the same content
(ft1 <- ftable(Titanic, col.vars = 1:4))
(ft2 <- ftable(Titanic, row.vars = 1))
(ft3 <- ftable(Titanic, row.vars = 1:2))
(ft4 <- ftable(Titanic, row.vars = 1:3))
(ft5 <- ftable(Titanic, row.vars = 1:4))
## What tablines() returns
tablines(fftable(ft2))
## LaTeX (booktabs/non-booktabs) versions
toLatex(ft1, do.table=FALSE)
toLatex(ft1, booktabs=FALSE)
toLatex(ft1, method="col.compact")
toLatex(ft1)
toLatex(ft2)
toLatex(ft3)
toLatex(ft4)
toLatex(ft5, booktabs=FALSE)
toLatex(ft5, method="col.compact")
toLatex(ft5)
## ``poor-man's approach'' for creating lines of a LaTeX table
set.seed(271)
tab <- matrix(runif(6), ncol=3)
ftab <- formatC(tab, digits=4, format="f")
cattablines(ftab)
rownames(ftab) <- LETTERS[1:nrow(ftab)]
cattablines(ftab)