Assembles a Quarto knitr table chunk.
Usage
tbl_chunk(
body,
label,
tbl_cap,
tbl_subcap = NULL,
tbl_cap_location = NULL,
tbl_colwidths = NULL,
tbl_column = NULL,
column = NULL,
layout_ncol = NULL,
layout_nrow = NULL,
layout = 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
labelcode 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-capcode chunk option. EitherNULLto omit or a character vector.- tbl_subcap
Table subcaptions. Set as Quarto's
tbl-subcapcode chunk option. EitherNULLto omit or a character vector.- tbl_cap_location
Location to place table captions. Set as Quarto's
tbl-cap-locationcode chunk option. EitherNULLto omit or one of"top","bottom"or"margin".- tbl_colwidths
Apply explicit table column widths for Markdown grid tables and pipe tables that are more than
columnscharacters 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.NULLto omit thetbl-colwidthschunk option.
- tbl_column
Quarto article layout class for the figure output. Set as Quarto's
tbl-columncode chunk option. EitherNULLto omit or one of"body""body-outset""body-outset-left""body-outset-right""page""page-left""page-right""page-inset""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
columncode chunk option. EitherNULLto omit or one of"body""body-outset""body-outset-left""body-outset-right""page""page-left""page-right""page-inset""page-inset-left""page-inset-right""screen""screen-left""screen-right""screen-inset""screen-inset-shaded""screen-inset-left""screen-inset-right""margin"
- layout_ncol
Number of columns to arrange the chunk output in. Set as Quarto's
layout-ncolcode chunk option. EitherNULLto omit or a positive integerish number.- layout_nrow
Number of rows to arrange the chunk output in. Set as Quarto's
layout-nrowcode chunk option. EitherNULLto omit or a positive integerish number.- layout
Custom layout proportions. Set as Quarto's
layoutcode chunk option. A list of numeric vectors where each vector defines the column proportions of a row. Note that the numbers in a row are arbitrary and don’t need to add up to a particular total.
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()