md_table: Markdown tables (4.10 extension)

View source: R/md-table.R

md_tableR Documentation

Markdown tables (4.10 extension)

Description

Take a list of data frames or matrices and pass them to knitr::kable() to create a glue vector containing valid markdown tables.

Usage

md_table(x, ...)

Arguments

x

An R object to be formatted as a table.

...

Arguments passed to knitr::kable()

Details

FM enables the table extension, where an additional leaf block type is available.

A table is an arrangement of data with rows and columns, consisting of a single header row, a delimiter row separating the header from the data, and zero or more data rows.

Each row consists of cells containing arbitrary text, in which inlines are parsed, separated by pipes (|). A leading and trailing pipe is also recommended for clarity of reading, and if there’s otherwise parsing ambiguity. Spaces between pipes and cell content are trimmed. Block-level elements cannot be inserted in a table.

The delimiter row consists of cells whose only content are hyphens (-), and optionally, a leading or trailing colon (:), or both, to indicate left, right, or center alignment respectively (see align in knitr::kable()).

Value

A glue vector of length one, with each element or row of x separated by a newline.

See Also

Other leaf block functions: md_blank(), md_chunk(), md_fence(), md_heading(), md_indent(), md_label(), md_paragraph(), md_reference(), md_rule(), md_setext()

Other markdown extensions: md_issue(), md_strike()

Examples

md_table(mtcars)
md_table(data.frame(x = LETTERS[1:3], y = 1:3), align = c("cc"))

gluedown documentation built on Nov. 2, 2023, 5:48 p.m.