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
)
a data.frame or a flextable
object or a gtsummary
object
row names to be displayed
column names to be displayed
alignment of columns (default: numbers to the right, others to the left)
extra cell padding
caption of table
text for missing values (default: ""
)
type of formatting the table - valid options are "latex"
, "html"
, "markdown"
, "pandoc"
and "rst"
formatting of dates, will be evaluated with format2()
decimal separator, defaults to dec_mark()
thousands separator, defaults to big_mark()
vector with two values that replace TRUE
and FALSE
display the column indices as percentages using format2()
- example: columns.percent = c(2, 3)
display column names in bold
number of decimal places to round up for numbers
number of decimal places to round to when using columns.percent
number of white lines to print before the table
number of white lines to print after the table
only useful when input is a Flextable: force printing
character
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.
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 |
#>
#>