replace_with_values.Rd
Replaces placeholder text in a character vector with user specified values.
replace_with_values(
x,
values,
placeholder = function(i) {
paste0("[[", i, "]]")
},
...
)
A character vector
A vector of values with which to replace placeholder text.
A function defining
how to identify placeholder text based
on the index position of the vector
values
.
Additional parameters for the
placeholder
function.
# 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 ) )
#> [1] "Value: 1" "Value: 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 )
#> [1] "Value: 1" "Value: 2"