knitr::opts_chunk$set(echo = TRUE, fig.path = "man/figures/README-")
r badger::badge_custom("dev version", as.character(packageVersion("btabler")),
"blue", "https://github.com/CTU-Bern/btabler")
btabler
is a package which adds wraps the xtable
package, adding additional
functionality such as merging header columns.
Note that btabler
does not produce HTML tables. If using .Rmd
, output
should be
pdf_document
.
The package can be installed from the CTU Bern universe via
install.packages('btabler', repos = 'https://ctu-bern.r-universe.dev')
Load it as usual:
library(btabler)
Create your tables via whatever means and pass them to the btable
function:
df <- data.frame(name = c("", "Row 1", "Row2"), out_t = c("Total", "t1", "t1"), out_1 = c("Group 1", "g11", "g12"), out_2 = c("Group 2", "g21", "g22")) btable(df, nhead = 1, nfoot = 0, caption = "Table1")
btable
returns the latex code for the table you passed, which can be easily used
with sweave to create tables in reports.
knitr::include_graphics("man/figures/basic.png")
As an example for further modifications, column widths can also be modified using
the aligntot
argument:
btable(df, nhead = 1, nfoot = 0, caption = "Table1", aligntot = "p{3cm}p{1.5cm}p{1.5cm}p{1.5cm}")
knitr::include_graphics("man/figures/aligntot_width.png")
See the vignette for further examples of using btabler
vignette("btabler")
btabler
tables are only interpretable by LaTeX when a few packages are loaded.
It is recommended to place the following code in the header of your .tex
file
or .Rmd
# .tex \usepackage{longtable} \usepackage{booktabs} \usepackage{float} \usepackage{array} # .Rmd header-includes: - \usepackage{longtable} - \usepackage{booktabs} - \usepackage{float} - \usepackage{array}
Other things like custom column types can also be added to the header (see the vignette for an example)
vignette("btabler")
btabler
provides basic templates in Rmd
and Rnw
formats:
use_btabletemplate("filename", "Rmd")
The package logo was created with ggplot2
and hexSticker
with icons from Font Awesome (via the emojifont package).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.