md_table: Generate a simple Markdown pipe table

View source: R/markdown.R

md_tableR Documentation

Generate a simple Markdown pipe table

Description

A minimal Markdown table generator using the pipe | as column separators.

Usage

md_table(x, digits = NULL, na = NULL, newline = NULL, limit = NULL)

Arguments

x

A 2-dimensional object (e.g., a matrix or data frame).

digits

The number of decimal places to be passed to round(). It can be a integer vector of the same length as the number of columns in x to round columns separately. The default is 3.

na

A character string to represent NA values. The default is an empty string.

newline

A character string to substitute ⁠\n⁠ in x (because pipe tables do not support line breaks in cells). The default is a space.

limit

The maximum number of rows to show in the table. If it is smaller than the number of rows, the data in the middle will be omitted. If it is of length 2, the second number will be used to limit the number of columns. Zero and negative values are ignored.

Details

The default argument values can be set via global options with the prefix xfun.md_table., e.g., ⁠options(xfun.md_table.digits 2, xfun.md_table.na = 'n/a')⁠.

Value

A character vector.

See Also

knitr::kable() (which supports more features)

Examples

xfun::md_table(head(iris))
xfun::md_table(mtcars, limit = c(10, 6))

xfun documentation built on Nov. 1, 2024, 1:06 a.m.