str_detect_replace | R Documentation |
A wrapper for stringr's str_detect
so that one can detect strings with a particular pattern and replacement them outright. Vectorized over patterns and replacements.
str_detect_replace(string, pattern, replacement)
string |
(chr vector) A character vector. |
pattern |
(chr vector) Pattern to look for (REGEX). |
replacement |
(chr vector) A vector of values to replace with. |
A character vector.
str = 1:99 + c(".", ",", ":") #example str vector
str_detect_replace(str, pattern = c("\\.", ",", ":"), replacement = c("dot", "comma", "colon")) #replace by pattern
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.