Learn R Programming

teal.reporter (version 0.6.0)

eval_code-teal_report: Evaluate code in qenv

Description

Evaluate code in qenv

Usage

# S4 method for teal_report
eval_code(object, code, code_block_opts = list(), ...)

Value

teal_reporter environment with the code evaluated and the outputs added to the card or qenv.error if evaluation fails.

Arguments

object

(teal_report)

code

(character, language or expression) code to evaluate. It is possible to preserve original formatting of the code by providing a character or an expression being a result of parse(keep.source = TRUE).

code_block_opts

(list) Additional options for the R code chunk in R Markdown.

...

(dots) additional arguments passed to future methods.

Details

eval_code() evaluates given code in the qenv environment and appends it to the code slot. Thus, if the qenv had been instantiated empty, contents of the environment are always a result of the stored code.

See Also

within.qenv

Examples

Run this code
td <- teal.data::teal_data()
td <- teal.code::eval_code(td, "iris <- iris")
tr <- as.teal_report(td)
tr <- teal.code::eval_code(tr, "a <- 1")
tr <- teal.code::eval_code(tr, "b <- 2L # with comment")
tr <- teal.code::eval_code(tr, quote(library(checkmate)))
tr <- teal.code::eval_code(tr, expression(assert_number(a)))
teal_card(tr)

Run the code above in your browser using DataLab