Assembles a Quarto knitr table chunk.
Usage
tbl_chunk(
body,
label,
tbl_cap,
tbl_subcap = NULL,
tbl_colwidths = NULL,
tbl_column = NULL,
column = NULL
)
Arguments
- body
R code to insert into the code chunk's body. A character scalar.
- label
Unique code chunk label. Set as Quarto's
label
code chunk option. A character scalar that starts with"tbl-"
and only contains letters, numbers, underscores (_
) and dashes (-
).- tbl_cap
Table caption. Set as Quarto's
tbl-cap
code chunk option. EitherNULL
to omit or a character vector.- tbl_subcap
Table subcaptions. Set as Quarto's
tbl-subcap
code chunk option. EitherNULL
to omit or a character vector.- tbl_colwidths
Apply explicit table column widths for Markdown grid tables and pipe tables that are more than
columns
characters wide (72 by default).Some formats (e.g. HTML) do an excellent job automatically sizing table columns and so don’t benefit much from column width specifications. Other formats (e.g. LaTeX) require table column sizes in order to correctly flow longer cell content (this is a major reason why tables > 72 columns wide are assigned explicit widths by Pandoc).
This can be specified as:
"auto"
: Apply Markdown table column widths except when there is a hyperlink in the table (which tends to throw off automatic calculation of column widths based on the Markdown text width of cells)."auto"
is the default for HTML output formats."true"
: Always apply Markdown table widths."true"
is the default for all non-HTML formats."false"
: Never apply Markdown table widths.A numeric vector (e.g.
c(40, 30, 30)
): Array of explicit width percentages.NULL
to omit thetbl-colwidths
chunk option.
- tbl_column
Quarto article layout class for the figure output. Set as Quarto's
tbl-column
code chunk option. EitherNULL
to omit or one of"body"
"body-outset"
"body-outset-left"
"body-outset-right"
"page"
"page-left"
"page-right"
"page-inset-left"
"page-inset-right"
"screen"
"screen-left"
"screen-right"
"screen-inset"
"screen-inset-shaded"
"screen-inset-left"
"screen-inset-right"
"margin"
- column
Quarto article layout class for all of the code chunk's output. Set as Quarto's
column
code chunk option. EitherNULL
to omit or one of"body"
"body-outset"
"body-outset-left"
"body-outset-right"
"page"
"page-left"
"page-right"
"page-inset-left"
"page-inset-right"
"screen"
"screen-left"
"screen-right"
"screen-inset"
"screen-inset-shaded"
"screen-inset-left"
"screen-inset-right"
"margin"
Details
Use substitute together with deparse1()
to convert R expressions to a character scalar as expected by param body
:
deparse1(expr = substitute(do_something()),
collapse = "\n")
See also
Other code chunk functions:
chunks()
,
fig_chunk()
,
read_chunk_toml()