Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

toKable

Convert tabular object to knitr_kable format.


Description

Converts the output of the tabular and related functions to a format consistent with the output of the kable function, so that it can be customized using the kableExtra package.

Usage

toKable(table, format = getKnitrFormat(), booktabs = TRUE, ...)
getKnitrFormat(default = "latex")

Arguments

table

An object of class tabular.

format

The type of knitr_kable object desired; currently only "latex" and "html" are supported.

booktabs

Should the table be rendered in booktabs style? This only affects LaTeX output.

...

Additional arguments to pass to html.tabular or latex.tabular.

default

The default type of output if not running in a knitr document.

Value

An object of class knitr_kable, suitable for passing to functions in the kableExtra package.

See Also

Examples

if (requireNamespace("kableExtra")) {
  tab <-  tabular( (Species + 1) ~ (n=1) + Format(digits=2)*
          (Sepal.Length + Sepal.Width)*(mean + sd), data=iris )
  print(kableExtra::kable_styling(toKable(tab), latex_options = "striped"))
  cat("\n")
  toKable(tab, format = "html", options = list(HTMLcaption = "Fisher's iris data"))
}

tables

Formula-Driven Table Generation

v0.9.6
GPL-2
Authors
Duncan Murdoch
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.