code_chunk()
assembles a knitr code chunk as a character vector.
setup_chunk()
is a wrapper around code_chunk()
to create setup chunks. By
default it uses include = FALSE
and inserts knitr::opts_chunk$set(echo = TRUE)
into the chunk body. These are helper functions to write R Markdown
bodies for use_rmarkdown()
.
code_chunk(chunk_code, chunk_name = NULL, chunk_args = NULL)
setup_chunk(chunk_code = NULL, chunk_args = list(include = FALSE))
An expression. Surround with {}
to capture multiple
lines.
The name of the chunk
A list
of chunk options
a character vector
# \donttest{
setup_chunk()
#> ```{r setup, include = FALSE}
#> knitr::opts_chunk$set(echo = TRUE)
#> ```
code_chunk({
yml() %>%
yml_output(pdf_document())
}, chunk_name = "yml_example")
#> ```{r yml_example}
#> yml() %>% yml_output(pdf_document())
#> ```
# }