pp: Ruby-style string interpolation

Description Usage Arguments Examples

View source: R/utils.R

Description

Writing strings for messages with variable content often involves a mess of nested calls to paste. Use this function to reduce the clutter created by these. Lifted from https://github.com/robertzk/productivus/blob/master/R/pp.R

Usage

1
pp(..., envir = parent.frame(), sep = "", collapse = "")

Arguments

...

a character vector, or a (possibly nested) list of character vectors.

envir

environment. The environment to fetch values to use in interpolation.

sep

character. Passed into the collapse argument of base::paste.

collapse

character. Passed into the collapse argument of base::paste.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
  x <- 5
  pp("we assigned ${x} to x")
  x <- "this time we'll use a string"
  pp("we assigned ${x} to x, and the value of x changed")
  .small_env <- new.env()
  .small_env$x <- "this is inside an environment"
  pp("if we declare an environment, we see that x is ${x} there", envir = .small_env)

## End(Not run)

abelcastilloavant/csmpi documentation built on May 24, 2019, 7:21 p.m.