create_table | R Documentation |
Function wraps the gt package for creating tables from a data.frame object. Function incorporates the gt package to create tables primarily for R Markdown/Quarto documents. The function offers a quick alternative if just limited styling and formatting are required.
create_table(
df = NULL,
title = NULL,
subtitle = NULL,
container_width_px = NULL,
container_height_px = NULL,
rowname_col = NULL,
col_label_lst = NULL,
col_width_lst = NULL,
header_line = FALSE,
caption = NULL,
source_note = NULL,
hor_scroll_bar = FALSE,
ver_scroll_bar = FALSE,
decimals_lst = NULL,
footnote_title = NULL,
footnote_col_head_lst = NULL,
footnote_body_lst = NULL
)
df |
A data.frame from which to display a table. |
title |
A string that sets the table's title. The string can contain R markdown/html style syntax. |
subtitle |
A string that sets the table's subtitle. The string can contain R markdown/html style syntax. |
container_width_px |
A numeric that sets the overall container width in pixels. |
container_height_px |
A numeric that sets the overall container height in pixels. |
rowname_col |
The column name from 'df' to use as row captions to be placed in the display table stub. |
col_label_lst |
A list that resets the table's column labels. The list's key is the old label and the value is the new label. Initially the old labels will be 'df's column names. |
col_width_lst |
A list that sets the table's column widths. The list's key is a column's index number and value is the column width in pixels. Both the key and value are strings. |
header_line |
A logical which if TRUE will place a bold, thick line between the header row and table body. |
caption |
A string that sets the table caption which appears above the title to use as cross-referencing in R Markdown/Quarto document. The string can contain R markdown/html style syntax. |
source_note |
A string located at the bottom of the table that notes the table's source. The string can contain R markdown/html style syntax. |
hor_scroll_bar |
A logical that controls the appearance of the horizontal scroll bar. |
ver_scroll_bar |
A logical that controls the appearance of the vertical scroll bar. |
decimals_lst |
A list that describes the decimals for one or more table columns. The list should have the following key-value pairs:
|
footnote_title |
A string at the bottom of the table that footnotes the table's title. |
footnote_col_head_lst |
A list that describes the text/location of a footnote for column headings. The list should have the following key-value pairs:
|
footnote_body_lst |
A list that describes the text/location of a footnote within the body of the table. The list should have the following key-value pairs:
|
A gt
object of class "gt_tbl" which can be further modified.
library(gt)
library(glue)
library(purrr)
library(RplotterPkg)
RplotterPkg::create_table(
df = RplotterPkg::people,
container_width_px = 500,
col_label_lst = list(
col_0 = "ID",
col_1 = "First Name",
col_2 = "Last Name",
col_3 = "Age",
col_4 = "Address",
col_5 = "Spouse"
),
decimals_lst = list(
cols = 4,
decimal = 0
),
rowname_col = "ID",
source_note = "Source: *Chardon City Directory*",
footnote_title = "Employees are current",
footnote_col_head_lst = list(
footnote = "As reported on their job application",
col = c(2,3)
),
footnote_body_lst = list(
footnote = "Age is approximated",
col = 4,
row = c(1,2)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.