Wrapper function around pretty_DT() and ble() that automatically chooses to return a DT table or a kable table depending on the output type (html or latex). Specifically, if the requested output type is "html", a pretty DT table is returned, and if the requested output type is "latex", a pretty kable table is returned.

pretty_table(
  X,
  html = knitr::is_html_output(),
  digits = 3,
  sigfig = TRUE,
  rownames = TRUE,
  caption = "",
  na_disp = "NA",
  bold_function = NULL,
  bold_margin = NULL,
  bold_scheme = TRUE,
  bold_color = NULL,
  html_options = NULL,
  latex_options = NULL,
  return_df = FALSE
)

Arguments

X

Data frame or data matrix to display in table

html

Logical indicating whether the output should be in html format. If FALSE, output is in latex format.

digits

Number of digits to display for numeric values

sigfig

Logical. If TRUE, digits refers to the number of significant figures. If FALSE, digits refers to the number of decimal places.

rownames

Logical. Whether or not to show rownames in table. See DT::datatable() for details.

caption

The table caption.

na_disp

Character string to display if NA entry is found in table.

bold_function

Optional function or vector of functions to use for bolding entries, e.g. function(x) x == max(x) or function(x) x >= 0.5.

bold_margin

Specifies the margins of X that will be used to evaluate bold_function across, i.e., 0 = across entire matrix, 1 = across rows, and 2 = across columns. Required if bold_function = TRUE.

bold_scheme

Scalar or vector of logicals, indicating whether or not to apply bold_function to row if bold_margin = 1 and to column if bold_margin = 1, 2. Default is to apply bolding to all rows/columns.

bold_color

Color of bolded text.

html_options

List of additional named arguments to pass to pretty_DT().

latex_options

List of additional named arguments to pass to pretty_kable().

return_df

Logical. If TRUE, return data frame that was used as input into DT::datatable() in addition to the datatable output. If FALSE, only return the datatable output.

Value

A DT table in html format if html = TRUE and a kable table in latex format if html = FALSE. In addition, if return_df = TRUE, the data frame that was used to create the table is returned.