Vectorised over string, to replace underscores with spaces or vice versa.
str_replace_us(string) str_replace_sp(string)
| string | "Input vector. Either a character vector, or something coercible to one." (from |
|---|
"A character vector." (from ?stringr::str_replace_all)
These two functions are thin wrappers around str_replace_all() from the 'stringr' package.
They just pass a space (" ") or an underscore ("_") to the parameters pattern and replacement, automatically.
(Yes, I do this often enough to warrant adding two new functions to my namespace!)
txt <- "This_is_a_string" str_replace_us(txt)#> [1] "This is a string"txt <- "This is a string" str_replace_sp(txt)#> [1] "This_is_a_string"