dualTable(
    my_tbl,
    where="H",
    align=paste(rep('c', ncol(my_tbl)), collapse=''),
    caption="",
    css.class="gmisc_table breakboth",
    use.xtable=FALSE,
    files="",
    ...)

Arguments

my_tbl

The matrix/data.frame with the data.

where

Passed to latex. Specifies placement of floats if a table environment is used. Default is "H", which places the table in the exact location it appears in the document. To allow tables to appear in the middle of a page of text you might specify where="!htbp" to latex.default.

align

A character strings specifying column alignments, defaulting to paste(rep('c',ncol(my_tbl)),collapse='') to center. Valid alignments are l = left, c = center and r = right. You can also specify align='c|c' and other LaTeX tabular formatting. If you want to set the alignment of the rownames this string needst to be ‘ncol(x) + 1’, otherwise it automatically pads the string with a left alignment for the rownames.

caption

Adds a table caption.

css.class

The html CSS class for the table. This allows directing html formatting through CSS directly at all instances of that class. Default includes breakboth class. This inserts a page break before and after the table, which prevents tables from being broken up between pages when printed from HTML or rendered as an EPUB document.

use.xtable

Boolean argument (defaults to FALSE) indicating whether xtable is used.

files

Path to output file(s) to save text to. Default is ‘""’, which is prints to the standard output connection (typically the rendered .md file). Multiple files, or file(s) and stdout, are supported.

...

Passed onto htmlTable and/or latex.

Value

string Returns a character string containing the text for both the table to be rendered in HTML or PDF via LaTeX. String also contains HTML/Markdown comments to demarcate the location of the each code type, which is used later for post-processing markdown text files using renderMultiDocument.

Examples

# A simple output options(table_number=0) output <- matrix(1:4, ncol=2, dimnames = list(list("Row 1", "Row 2"), list("Column 1", "Column 2"))) dualTable(output, caption="Simple Test Table")
#> #> <!-- HTML_Start --> #> <!-- dualTable --> #> <table class='gmisc_table breakboth' style='border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;' > #> <thead> #> <tr><td colspan='3' style='text-align: left;'> #> **Table 1:** Simple Test Table</td></tr> #> <tr><th style='border-bottom: 1px solid grey; border-top: 2px solid grey;'></th> #> <th style='font-weight: 900; border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>Column 1</th> #> <th style='font-weight: 900; border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>Column 2</th> #> </tr> #> </thead> #> <tbody> #> <tr> #> <td style='text-align: left;'>Row 1</td> #> <td style='text-align: center;'>1</td> #> <td style='text-align: center;'>3</td> #> </tr> #> <tr> #> <td style='border-bottom: 2px solid grey; text-align: left;'>Row 2</td> #> <td style='border-bottom: 2px solid grey; text-align: center;'>2</td> #> <td style='border-bottom: 2px solid grey; text-align: center;'>4</td> #> </tr> #> </tbody> #> </table> #> <!-- LaTeX_Start dualTable #> %latex.default(my_tbl, file = f, append = TRUE, where = where, col.just = tex.align, caption = tmp_caption, ...)% #> \begin{table}[H] #> \caption{**Table 1:** Simple Test Table\label{my}} #> \begin{center} #> \begin{tabular}{lcc} #> \hline\hline #> \multicolumn{1}{l}{my}&\multicolumn{1}{c}{Column 1}&\multicolumn{1}{c}{Column 2}\tabularnewline #> \hline #> Row 1&$1$&$3$\tabularnewline #> Row 2&$2$&$4$\tabularnewline #> \hline #> \end{tabular}\end{center} #> \end{table} #> #> LaTeX_End -->
# An advanced output not_run({ output <- matrix(ncol=6, nrow=8) for (nr in 1:nrow(output)){ for (nc in 1:ncol(output)){ output[nr, nc] <- paste0(nr, ":", nc) } } dualTable(output, align=paste(rep('r', ncol(output)), collapse=''), header = paste(c("1st", "2nd", "3rd", "4th", "5th", "6th"), "hdr"), rnames = paste(c("1st", "2nd", "3rd", paste0(4:8, "th")), "row"), rgroup = paste("Group", LETTERS[1:3]), n.rgroup = c(2,4,nrow(output) - 6), cgroup = c("", "Cgroup 1", "Cgroup 2&dagger;"), n.cgroup = c(2,2,2), caption="Basic table with both column spanners (groups) and row groups", tfoot="&dagger; A table footer commment", cspan.rgroup = 2, col.columns = c(rep("none", 2), rep("#F5FBFF", 4)), col.rgroup = c("none", "#F7F7F7"), css.cell = "padding-left: .5em; padding-right: .2em;") })