View source: R/str-replace_vec.R
str_replace_vec | R Documentation |
String replace multiple strings in a vector.
str_replace_vec(string, replace)
string |
Input vector. Either a character vector, or something coercible to one. |
replace |
A character vector where the names are the patterns to look
for and the values are the replacement values |
str_replace_vec()
is a vectorized form of stringr::str_replace()
.
This is different from passing a named vector to stringr::str_replace_all
,
which performs multiple replacements but to all pattern matches in a string.
A character vector the same length as
string
/pattern
/replacement
.
stringr::str_replace()
and stringr::str_replace_all()
fruits <- c("two apples", "nine pears")
str_replace_vec(fruits, c("two" = "three", "nine" = "ten"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.