Skip to contents

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.

Usage

code_chunk(code, ..., lang = "R")

Arguments

code

A character string containing the R code.

...

Additional named parameters to be included as chunk options (e.g., echo = TRUE). Check knitr options/ for more details.

lang

(character(1)) See knitr::knit_engines.

Value

An object of class code_chunk.

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
#>