Skip to contents

Formats a table for reports with knitr::kable(), or returns it unchanged, so report code does not depend on the table package.

Usage

table_facade(df, caption, digits = getOption("digits"), kable = TRUE)

Arguments

df

data.frame to display

caption

table caption

digits

number of digits (default from options)

kable

if TRUE use knitr::kable (requires knitr)

Value

a knitr_kable table, or df unchanged when kable = FALSE

Examples

table_facade(head(iris, 3), caption = "Iris preview")
#> 
#> 
#> Table: Iris preview
#> 
#> | Sepal.Length| Sepal.Width| Petal.Length| Petal.Width|Species |
#> |------------:|-----------:|------------:|-----------:|:-------|
#> |          5.1|         3.5|          1.4|         0.2|setosa  |
#> |          4.9|         3.0|          1.4|         0.2|setosa  |
#> |          4.7|         3.2|          1.3|         0.2|setosa  |