How kableExtra works with kable()
masterkableExtra is not a standalone table generator. Instead, it is an extension package designed to add features to the output of knitr::kable() (or the kbl() alternative) using the R pipe operator (%>%).
Key concepts:
- Pipable syntax: You chain
kableExtrafunctions onto a table object to layer styling and structural elements. - Unified functions: Most functions are format-agnostic. They detect whether you are rendering to HTML or LaTeX (based on the format specified in
kable()or the globalknitr.table.formatoption) and apply the appropriate styling automatically. - kbl() function: A recommended alternative to
kable()that provides better documentation and improved format detection.
library(kableExtra)
dt <- mtcars[1:5, 1:4]
# Example of the pipable pattern
kbl(dt) %>%
kable_styling(bootstrap_options = "striped") %>%
footnote(c("table footnote"))