Learn R Programming

ymlthis (version 0.1.7)

code_chunk: Write code chunks programmatically

Description

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().

Usage

code_chunk(chunk_code, chunk_name = NULL, chunk_args = NULL)

setup_chunk(chunk_code = NULL, chunk_args = list(include = FALSE))

Value

a character vector

Arguments

chunk_code

An expression. Surround with {} to capture multiple lines.

chunk_name

The name of the chunk

chunk_args

A list of chunk options

Examples

Run this code
# \donttest{
setup_chunk()

code_chunk({
  yml() %>%
    yml_output(pdf_document())
}, chunk_name = "yml_example")
# }

Run the code above in your browser using DataLab