This function creates a code_chunk
object, which represents an R Markdown
code chunk. It stores the R code and any specified chunk options (e.g., echo
, eval
).
These objects are typically processed later to generate the final R Markdown text.
Arguments
- code
A character string containing the R code.
- ...
Additional named parameters to be included as chunk options (e.g.,
echo = TRUE
). Checkknitr
options/ for more details.- lang
(
character(1)
) Seeknitr::knit_engines
.
Examples
my_chunk <- code_chunk("x <- 1:10", echo = TRUE, message = FALSE)
class(my_chunk)
#> [1] "code_chunk"
attributes(my_chunk)$param
#> $echo
#> [1] TRUE
#>
#> $message
#> [1] FALSE
#>