Debian Codegraph @

man/md_table.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/markdown.R
3 \name{md_table}
4 \alias{md_table}
5 \title{Generate a simple Markdown pipe table}
6 \usage{
7 md_table(
8 x,
9 digits = NULL,
10 na = NULL,
11 newline = NULL,
12 limit = NULL,
13 escape = NULL
14 )
15 }
16 \arguments{
17 \item{x}{A 2-dimensional object (e.g., a matrix or data frame).}
18
19 \item{digits}{The number of decimal places to be passed to \code{\link[=round]{round()}}. It can
20 be a integer vector of the same length as the number of columns in \code{x} to
21 round columns separately. The default is \code{3}.}
22
23 \item{na}{A character string to represent \code{NA} values. The default is an
24 empty string.}
25
26 \item{newline}{A character string to substitute \verb{\\n} in \code{x} (because pipe
27 tables do not support line breaks in cells). The default is a space.}
28
29 \item{limit}{The maximum number of rows to show in the table. If it is
30 smaller than the number of rows, the data in the middle will be omitted. If
31 it is of length 2, the second number will be used to limit the number of
32 columns. Zero and negative values are ignored.}
33
34 \item{escape}{Whether to backslash-escape special Markdown characters
35 (\verb{\\`, *, _, [, ], <, >, ~, \\}) in table cells. This prevents cell
36 content from being interpreted as Markdown (e.g., \verb{<foo:bar>} being treated
37 as a link). It can take a logical value (\code{TRUE} means all columns and
38 \code{FALSE} means none), or a vector of column indices or names to escape
39 selectively. The default is \code{FALSE}.}
40 }
41 \value{
42 A character vector.
43 }
44 \description{
45 A minimal Markdown table generator using the pipe \code{|} as column separators.
46 }
47 \details{
48 The default argument values can be set via global options with the prefix
49 \code{xfun.md_table.}, e.g., \verb{options(xfun.md_table.digits 2, xfun.md_table.na = 'n/a')}.
50 }
51 \examples{
52 xfun::md_table(head(iris))
53 xfun::md_table(mtcars, limit = c(10, 6))
54 xfun::md_table(data.frame(x = "Hello <world>", y = 1), escape = TRUE)
55 xfun::md_table(data.frame(x = "Hello <world>", y = 1), escape = "x")
56 }
57 \seealso{
58 \code{\link[knitr:kable]{knitr::kable()}} (which supports more features)
59 }