Assembles a Quarto knitr figure chunk.
Usage
fig_chunk(
body,
label,
fig_cap = NULL,
fig_subcap = NULL,
fig_cap_location = NULL,
fig_column = NULL,
fig_width = NULL,
fig_height = NULL,
fig_pos = "H",
fig_link = NULL,
column = NULL,
layout_ncol = NULL,
layout_nrow = NULL,
layout = NULL,
out_width = NULL,
out_height = 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"fig-"and only contains letters, numbers, underscores (_) and dashes (-).- fig_cap
Figure caption. Set as Quarto's
fig-capcode chunk option. EitherNULLto omit or a character vector.- fig_subcap
Figure subcaptions. Set as Quarto's
fig-subcapcode chunk option. EitherNULLto omit or a character vector.- fig_cap_location
Location to place figure captions. Set as Quarto's
fig-cap-locationcode chunk option. EitherNULLto omit or one of"top","bottom"or"margin".- fig_column
Quarto article layout class for the figure output. Set as Quarto's
fig-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"
- fig_width
Width of the plot (in inches), to be used in the graphics device. Set as Quarto's
fig-widthcode chunk option. EitherNULLto omit or a numeric scalar.- fig_height
Height of the plot (in inches), to be used in the graphics device. Set as Quarto's
fig-heightcode chunk option. EitherNULLto omit or a numeric scalar.- fig_pos
LaTeX figure position arrangement to be used in
\begin{figure}[]. Set as Quarto'sfig-poscode chunk option. EitherNULLto omit, a character scalar, orFALSEfor no figure position specifier, which is sometimes necessary with custom figure environments (such assidewaysfigure).- fig_link
Hyperlink target for the figure. Set as Quarto's
fig-linkcode chunk option. EitherNULLto omit or a character scalar.- 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.- out_width
Width of the plot in the output document, which can be different from its physical
fig_width, i.e., plots can be scaled in the output document. Set as Quarto'sout-widthcode chunk option. EitherNULLto omit or a character scalar.- out_height
Height of the plot in the output document, which can be different from its physical
fig_height, i.e., plots can be scaled in the output document. Set as Quarto'sout-heightcode chunk option. EitherNULLto omit or a character scalar.
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(),
read_chunk_toml(),
tbl_chunk()