tbl_markdown: Print Table as Markdown, LaTeX of HTML

View source: R/data.frame.R

tbl_markdownR Documentation

Print Table as Markdown, LaTeX of HTML

Description

Prints a data.frame as Markdown, LaTeX or HTML using knitr::kable(), with bold headers and Dutch number formats.

Usage

tbl_markdown(
  x,
  row.names = rownames(x),
  column.names = colnames(x),
  align = NULL,
  padding = 2,
  caption = "",
  na = "",
  type = "markdown",
  format.dates = "dd-mm-yyyy",
  decimal.mark = dec_mark(),
  big.mark = big_mark(),
  logicals = c("X", ""),
  columns.percent = NA,
  column.names.bold = TRUE,
  round.numbers = 2,
  round.percent = 1,
  newlines.leading = 0,
  newlines.trailing = 2,
  print = TRUE
)

Arguments

x

a data.frame or a flextable object or a gtsummary object

row.names

row names to be displayed

column.names

column names to be displayed

align

alignment of columns (default: numbers to the right, others to the left)

padding

extra cell padding

caption

caption of table

na

text for missing values (default: "")

type

type of formatting the table - valid options are "latex", "html", "markdown", "pandoc" and "rst"

format.dates

formatting of dates, will be evaluated with format2()

decimal.mark

decimal separator, defaults to dec_mark()

big.mark

thousands separator, defaults to big_mark()

logicals

vector with two values that replace TRUE and FALSE

columns.percent

display the column indices as percentages using format2() - example: columns.percent = c(2, 3)

column.names.bold

display column names in bold

round.numbers

number of decimal places to round up for numbers

round.percent

number of decimal places to round to when using columns.percent

newlines.leading

number of white lines to print before the table

newlines.trailing

number of white lines to print after the table

print

only useful when input is a Flextable: force printing

Details

When in an R Markdown rapport a table is printed using this function, column headers only print well if newlines.leading >= 2, or by manually using cat("\\n\\n") before printing the table.

Value

character

See Also

knitr::kable()

Examples

tbl_markdown(mtcars[1:6, 1:6], padding = 1)

certe-medical-epidemiology/certetoolbox documentation built on April 17, 2025, 3:24 a.m.