Learn R Programming

simsalapar (version 1.0-12)

wrapLaTable: Wrapper for a floating LaTeX Table

Description

wrapLaTable() wraps (a table and tabular environment) around the lines of the body of a LaTeX table and utilizes writeLines() to write the LaTeX table.

Usage

wrapLaTable(x, align, do.table = TRUE, placement = "htbp", center = TRUE,
            fontsize = "normalsize", booktabs = TRUE,
            caption = NULL, label = NULL)

Value

a “LaTeX table”, of class "Latex" (where the

print method uses writeLines()).

Arguments

x

a character vector containing the lines of the body of the table (for “booktabs” tables, everything strictly between \midrule and \bottomrule). A table header can be passed via attributes of x.

align

table columns alignment string (e.g., "lcccS[table-format=1.2]", the notation of "S[...]" coming from the LaTeX package siunitx).

do.table

logical indicating whether a LaTeX ‘table’ environment should be used at all.

placement

(if do.table:) character string containing a LaTeX table placement string such as "htbp".

center

logical indicating whether centering should happen.

fontsize

character string giving a fontsize (such as "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large", "Large", "LARGE", "huge", or "Huge").

booktabs

logical indicating whether a LaTeX table in the format of the LaTeX booktabs package is created.

caption

(if do.table:) character string containing the table caption or NULL for no caption.

label

(if do.table:) character string containing the table label or NULL for no label.

Author

Marius Hofert.

Details

Note that necessary LaTeX packages (such as tabularx) have to be loaded in the preambel of the corresponding .tex or .Rnw file.

References

see simsalapar-package.

See Also

toLatex() where it is used to create a LaTeX table.

Examples

Run this code
ftab <- ftable(Titanic, row.vars = 1:2)
fftab <- fftable(ftab)
tlist <- tablines(fftab)

wrapLaTable(structure(tlist$body, head = tlist$head), align = tlist$align,
            caption="The Titanic data set.", label="tab:titanic")

Run the code above in your browser using DataLab