Learn R Programming

chronicle (version 0.1.0)

add_code: #' Add formatted code chunks to a chronicle Rmarkdown report

Description

Beware that code indentation of the chronicle call will affect the indentation of the chunk, so make sure not to leave unintended indentation in the 'code' parameter on this function call.

Usage

add_code(report, code, code_title = NULL, title_level = 2, eval = FALSE)

Arguments

report

character containing the text of an Rmarkdown report header (and possibly more chunks). Easily create one with chronicle::new_report()

code

Character string to be formated as an R code chunk. This code will not be excecuted when the report is rendered.

code_title

The title of the code section. Default is NULL.

title_level

Level of the section title (ie, number of # on Rmarkdown syntax.)

eval

Excecute the code sent to the chunk. Default is FALSE.

Value

The text of the Rmarkdown report plus an additional section with the code chunk.

Examples

Run this code
# NOT RUN {
html_report <- add_code(report = new_report(),
                        code_title = 'Code comes after this title',
                        code = 'f <- function(x, y){paste(x,y)}
f("a", "b")')
# }

Run the code above in your browser using DataLab