custom_kable | R Documentation |
This function uses knitr::kable()
and kableExtra::kable_styling
to build
a customized table that, in my opinion, looks better than the default.
custom_kable(
data,
digits = 3,
caption = NA,
col.names = NA,
row.names = NA,
format = NULL,
escape = TRUE,
format.args = list()
)
data |
A data frame or tibble. Matrices usually work, except when they don't. |
digits |
Maximum number of digits for numeric columns, passed to
|
caption |
The table caption. |
col.names |
A character vector of column names to be used in the table. |
row.names |
Logical: whether to include row names. By default, row names
are included if |
format |
A character string. Possible values are |
escape |
Boolean; whether to escape special characters when producing
HTML or LaTeX tables. When |
format.args |
A list of arguments to be passed to |
Missing values (NA
) in the table are displayed as NA
by
default. If you want to display them with other characters, you can set the
option knitr.kable.NA
, e.g. options(knitr.kable.NA = '')
to
hide NA
values.
A character vector of the table source code.
When using kable()
as a top-level expression, you do not
need to explicitly print()
it due to R's automatic implicit
printing. When it is wrapped inside other expressions (such as a
for
loop), you must explicitly print(kable(...))
.
See
https://bookdown.org/yihui/rmarkdown-cookbook/kable.html for some
examples about this function, including specific arguments according to the
format
selected.
See kable
and kable_styling
custom_kable(mtcars, caption = "A kable of mtcars")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.