View source: R/kable_wrapper.R
kable_wrapper | R Documentation |
This function generates a LaTeX table using the kableExtra
package.
It allows for customization of table appearance and formatting through various
parameters, including column specifications, captions, and labels.
Additionally, it can convert input data to a tibble if it is not already in
the appropriate format.
kable_wrapper(
tbl = NULL,
title,
lbl,
print_tbl = FALSE,
col_spec = NULL,
use_X_col = TRUE,
X_col_place = 1,
col_type = "c",
verbose = TRUE
)
tbl |
A data frame or tibble that contains the data to be displayed in the table. If NULL, an error is raised. |
title |
A character string representing the title of the table. |
lbl |
A character string representing the label for the table, used for referencing in LaTeX. |
print_tbl |
A logical value indicating whether to print the table to the console and copy it to the clipboard. Defaults to FALSE. |
col_spec |
A character vector specifying the alignment of columns. Options include "l" for left, "c" for center, and "r" for right alignment. If NULL, defaults will be applied. |
use_X_col |
A logical value indicating whether to use the "X" column type in the tabularx environment. Defaults to TRUE. |
X_col_place |
An integer indicating the position of the "X" column, defaults to 1 (first column). |
col_type |
A character string indicating the default column type for the table, with options "l", "c", or "r". Defaults to "c". |
verbose |
A logical value indicating whether to print messages during the execution of the function. Defaults to TRUE. |
Returns the generated LaTeX table as a character string.
## Not run:
# Example usage with a data frame
df <- data.frame(A = 1:3, B = c("X", "Y", "Z"))
kable_wrapper(tbl = df, title = "Sample Table", lbl = "tab:sample")
# Example with verbose turned off
kable_wrapper(tbl = df, title = "Sample Table", lbl = "tab:sample", verbose = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.