Learn R Programming

rscala (version 1.0.6)

strintrplt: Performs string interpolation with arbitrary R code.

Description

This function allows a character vector to have arbitrary Rcode embedded within it. The embedded Rcode --- placed between ${ and } --- is evaluated by default in the environment from which this function is called (not defined). Any number of instances of embedded Rcode is possible. The result of the function is a character vector in which the embedded Rcode is replaced by character representations of the results of evaluating the embedded Rcode.

Usage

strintrplt(snippet,envir=parent.frame())

Arguments

snippet
A character vector of length one which may contain multiple ${RCODE} substrings which will be replaced by a character representation of the result of evaluating RCODE. This character vector may contain many Rstatements a
envir
The environment in which to evaluate the embedded Rcode.

Examples

Run this code
strintrplt('val msg = "Current R version is @{paste0(R.Version()$major,".",R.Version()$minor)}"')
index <- 5
strintrplt('var i = @{index-1}')

Run the code above in your browser using DataLab