View source: R/S03_Utilities.R
replace_string | R Documentation |
Function that replaces a specified pattern found within a string (or vector of strings) with a user-specified pattern.
replace_string(s, to_replace, replace_with = "")
s |
A character vector. |
to_replace |
A character vector, the patterns to match and replace within each string. |
replace_with |
An optional character vector,
either of length one or of matching length to
|
A character string.
# Example string
x <- c( 'AA', 'AB', 'AC', 'DD' )
# Remove the letter 'A'
replace_string( x, 'A' )
# Replace the letter 'A' with '1'
replace_string( x, 'A', '1' )
# Replace multiple letters
replace_string( x, c( 'B', 'C' ), c( '1', '2' ) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.