Skip to contents

Write R chunk to template

Usage

add_chunk(
  x,
  echo = "false",
  warnings = "false",
  eval = "true",
  label = NULL,
  add_option = FALSE,
  chunk_op = NULL
)

Arguments

x

content within the R chunk to be written contained inside quotation marks

echo

repeat code into the document; default is false

warnings

Report warnings into console during render? Default is false

eval

Evaluate the chunk? default is true

label

What to name the chunk in the 'label:' section of the r code chunk; should be in snakecase

add_option

TRUE/FALSE add additional chunk options? default is FALSE

chunk_op

list of chunk options to add; example: c("output: true", "error: false)

Value

Write an additional R chunk into the template using this function. The code can be written as usual, just remember to put it entirely in quotes for the function to render it properly

Examples

add_chunk("plot(cars$speed, cars$distance)")
#> [1] "```{r} \n#| echo: false \n#| warning: false \n#| eval: true \nplot(cars$speed, cars$distance)\n``` \n"