knitr (version 0.1)

read_chunk: Read chunks from an external R script

Description

Chunks can be put in an external R script, and this function reads chunks into the current knitr session.

Usage

read_chunk(path)

Arguments

path
the path to the R script

Value

  • Code chunks are read into the current session so that future chunks can use the R code.

Details

The ref.label component in the pattern list (knit_patterns$get('ref.label')) defines the format of code chunks.

References

http://yihui.github.com/knitr/demo/reference/

Examples

Run this code
## the default format

## @knitr my-label
1 + 1
lm(y ~ x, data = data.frame(x = 1:10, y = rnorm(10)))

## later you can use <<my-label>>= to reference this chunk

Run the code above in your browser using DataCamp Workspace