Convenience wrapper for knitr::kable() designed to handle styling contingent upon output type (pdf vs. html). In addition to kable(), this wraps several other functions: kableExtra::pack_rows(), kableExtra::kable_styling(), kableExtra::column_spec().

format_table(
  content,
  out_type,
  digits = 2,
  caption = " ",
  booktabs = TRUE,
  longtable = FALSE,
  group_labels = NULL,
  group_starts = NULL,
  group_ends = NULL,
  bootstrap_options = c("striped", "condensed"),
  latex_options = c("basic", "HOLD_position"),
  full_width = FALSE,
  font_size = 10
)

Arguments

content

A data.frame or similar holding table content. It will be passed to kable().

out_type

The output type of the table. Specially handled values are "html", "pdf", which yield tables in html or latex/pdf format, respectively. Any other value will yield a 'pandoc' table. See 'format' argument to kable().

digits

Number of digits to right of decimal. See same name argument to kable().

caption

The table caption. See same name argument to kable().

booktabs

Enable latex package 'booktabs'. See same name argument to kable().

longtable

Enable latex package 'longtable'. See same name argument to kable().

group_labels

Labels assigned to groups of table rows. See kableExtra::pack_rows().

group_starts

Start of each group of table rows. See kableExtra::pack_rows().

group_ends

Start of each group of table rows. See kableExtra::pack_rows().

bootstrap_options

Used for html tables. See kableExtra::kable_styling().

latex_options

Used for pdf tables. See kableExtra::kable_styling().

full_width

Should table be full page width? See kableExtra::kable_styling()

font_size

Font size. See kableExtra::kable_styling()

Value

A formated table, per knitr::kable().

Details

Convenience wrapper for knitr::kable() designed to handle styling contingent upon output type (pdf vs. html). Allows separate formatting options depending on output document type.

See also

kable(), kable_styling(), pack_rows(), column_spec().

Author

David Braze davebraze@gmail.com