dualTable | R Documentation |
This is a function for outputting a more advanced table than what xtable, ztable, or kable()
allows.
It's aim is to provide the combined functionality of the the Hmisc latex()
and
htmlTable htmlTable
. See documentation of those functions for more details.
dualTable(
my_tbl,
where="H",
align=paste(rep('c', ncol(my_tbl)), collapse=''),
caption="",
css.class="gmisc_table breakboth",
use.xtable=FALSE,
files="",
...)
my_tbl |
The matrix/data.frame with the data. |
where |
Passed to |
align |
A character strings specifying column alignments, defaulting to |
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 |
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 |
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
.
# 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")
# 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†"),
n.cgroup = c(2,2,2),
caption="Basic table with both column spanners (groups) and row groups",
tfoot="† 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;")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.