replace_with_values: Replace Placeholders with Values

View source: R/S05-dimensions_and_text.R

replace_with_valuesR Documentation

Replace Placeholders with Values

Description

Replaces placeholder text in a character vector with user specified values.

Usage

replace_with_values(
  x,
  values,
  placeholder = function(i) {     paste0("[[", i, "]]") },
  ...
)

Arguments

x

A character vector

values

A vector of values with which to replace placeholder text.

placeholder

A function defining how to identify placeholder text based on the index position of the vector values.

...

Additional parameters for the placeholder function.

Examples

# Character vector with placeholder text
# '[[i]]' for the ith element to replace
x <- c( 'Value: [[1]]', 'Value: [[2]]' )
replace_with_values( x, c( 1, 2 ) )

# Custom function to replace different
# placeholder text
placeholder <- function( i ) paste0( '***', LETTERS[i] )
x <- c( 'Value: ***A', 'Value: ***B' )
replace_with_values( x, c( 1, 2 ), placeholder )


rettopnivek/pathdiagrams documentation built on April 6, 2022, 9:13 p.m.