demo_chunk: Builds a 'demo_code' object from a code chunk

Description Usage Arguments Details Value

View source: R/demo_chunk.R

Description

This function reads the source code from a given code chunk that has the value label set to the demo option; i.e., {r, demo = "my_label"}.

Usage

1
demo_chunk(label)

Arguments

label

String that gives the name of the label used in a chunk option. If left blank, current chunk is used.

Details

When run directly in a source file, demo_chunk() reads the text of the active file and extracts the relevant string of source code from the labelled chunk. (Important: this only works in RStudio.)

When run during the knitr::knit() process, demo_chunk() pulls the relevant chunk source during knitr::knit_hooks$set("source").

Value

An object of class demo_code


kbodwin/demoR documentation built on Nov. 10, 2019, 11:30 p.m.