Learn R Programming

rapport (version 0.3)

tpl.check: Check Template

Description

Checks if the examples of given template can be run without any error and if the same output would be returned by calling the template in "strict" mode.

Usage

tpl.check(fp)

Arguments

fp
a character vector containing template name (".tpl" extension is optional), file path or a text to be split by lines

Value

  • list of logicals - see details above

Details

Strict mode is a huge performance gain (principally with nested templates where the overhead of extra checks lead to exponential slowdown with every level of nested hierarchy) based on evals' check.output parameter: no checks would be performed on template body about outputs. Thanks to this, strict mode templates should be written considering the following requirements:

  • each block should return on the last line of the code,
  • each block should always return something on the last line (if you do not want to return anything, addNULLto the last line),
  • ggplot and lattice graphs should be always printed (of course on the last line),
  • a block resulting in a plot should not alter variables and data sets,
  • the template should be checked before live run withtpl.check.

tpl.check will print on the console some text messages about the result of the test (errors etc.), but will also return a list invisible. List elements:

  • run: if all blocks could run without error (TRUE/FALSE),
  • strict: if rapport in "performance" (strict) mode returns the same output (TRUE/FALSE).

If everything went fine and you get two TRUE values, update your template to use "performance" mode on default by adding "Strict: TRUE" to template header.

Examples

Run this code
tpl.check('example')

Run the code above in your browser using DataLab