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

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

Value

character

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.

See also

Examples

tbl_markdown(mtcars[1:6, 1:6], padding = 1)
#> 
#> 
#> |                   | **mpg** | **cyl** | **disp** | **hp** | **drat** | **wt** |
#> |-------------------|---------|---------|----------|--------|----------|--------|
#> |     Mazda RX4     |  21.0   |    6    |   160    |  110   |   3.90   |  2.62  |
#> |   Mazda RX4 Wag   |  21.0   |    6    |   160    |  110   |   3.90   |  2.88  |
#> |    Datsun 710     |  22.8   |    4    |   108    |   93   |   3.85   |  2.32  |
#> |  Hornet 4 Drive   |  21.4   |    6    |   258    |  110   |   3.08   |  3.21  |
#> | Hornet Sportabout |  18.7   |    8    |   360    |  175   |   3.15   |  3.44  |
#> |      Valiant      |  18.1   |    6    |   225    |  105   |   2.76   |  3.46  |
#> 
#>