create_table: Function wraps the gt package for creating tables from a...

View source: R/create_table.R

create_tableR Documentation

Function wraps the gt package for creating tables from a data.frame object

Description

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.

Usage

create_table(
  x,
  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,
  display_table = TRUE
)

Arguments

x

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 x 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 x'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 veritical 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:

  1. cols = (an integer vector of column indices from x)

  2. decimal = (an integer that defines the number of decimals for the column(s))

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:

  1. footnote = (the footnote text to be displayed at the bottom of the table)

  2. col = (an integer vector setting the footnote's column heading index location's)

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:

  1. footnote = (the footnote text to be displayed at the bottom of the table)

  2. col = (an integer vector setting the footnote's column index location's)

  3. row = (an integer vector setting the footnote's row index location's)

display_table

A logical which if TRUE (the default) will display the table. Otherwise a gt object of class "gt_tbl" is returned which can be further modified.

Value

A gt object of class "gt_tbl" which can be further modified.

Author(s)

Rick Dean


deandevl/RplotterPkg documentation built on Feb. 1, 2024, 8:02 p.m.