knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

library(rslates)

Introduction

Slate blueprints are just regular R source code files decorated with slates preprocessing directives. These directives define the inputs that will appear on the slate, the outputs and their source code, datasets imported, and so on.

The Slates preprocessor is responsible to convert decorated code to regular R source code that can be parsed and executed by the R interpreter by substituting in the source code the user-defined values of the inputs.

Comments

Comments come in three flavors (#, ## and ###). These affect what comments will be displayed, suppressed and/ or interpreted by the preprocessor.

| Type | Symbol | Contents Preprocessed | Supressed in Code | |:------------|:------:|:---------------------:|:-----------------:| | Single Hash | # | Yes | No | | Double Hash | ## | Yes | Yes | | Triple Tash | ### | No | Yes |

Single Hash (#)

A regular R comment. This comment will show up in the final source that is provided to the user. Any preprocessor directives included in the comment are interpreted by the preprocessor and removed from the source. This type of comment is mostly used to provide the user with an explanation of what the resulting source code is doing.

Double Hash (##)

Will suppressed from user code, but preprocessing directives are interpreted. This type of comment is mostly used to assure that included preprocessor directives do not appear in the generated source code.

Triple Hash (###)

These are used to comment the blueprint source code itself, as they will be suppressed from the user code and ignored by the preprocessor.

Inputs, Groups and Pages

Inputs, groups and pages are defined through the $@input, $@group and $@page directives. After evaluation, these directives are scrubbed from the user code, and so can be placed outside of comments. However, placing them in double-hash comments may facilitate code-formatting by avoiding unnecessary empty lines in the user code.

Inputs

Syntax:

$@input name, type [, default] [, description=value1, ... ] ]

Alternate syntax:

$@input name(type [, default] [, description=value1, ... ] ])

Parameters

Mandatory

Optional

Usage

In the simplest case, an input may be defined with just a name. In this case it will assume the default character type. The default value will depend on the input type.

## defines an input 'x' of type 'character' (the default input type).
## $@input x

The input type and default value can be specified with or without parameter names.

## defines a 'numeric' input with the name 'num_samples' and default value 10.
## $@input num_samples(numeric, 10)
## $@input num_samples(type = numeric, default = 10)

Additional parameters must be specified by name. Common user-interface options include description, that determines the tooltip text for the input and pretty.name that, if provided, will be used in the user-interface instead of the variable name.

## $@input x(expression, expression(1:10), description="x coordinates for the plot.", pretty.name = "x-coordinates")

Note: for convenience it is not required to quote the input type parameter, although one may do so if desired. $@input x(character) is equivalent to $@input x("character").

Groups

$@group name(layout, ...)

Outputs and Datasets

$@output name(type, ...) ... $@end-output

$@dataset name(type, ...) ... $@end-dataset

Variable Substitution

${options:varname}

${default_options:: options1:varname1, options2:varname2, ...}

Conditional Output

$@if expression ... $@end-if

Imports

Import types:

$@import file filename [end]

$@end-import


amar00k/rslates documentation built on May 25, 2021, 1:12 p.m.