Replace all occurance of 'pattern' in all non numeric columns from a tbl.

tbl_replace_string(tbl, pattern, replacement)

Arguments

tbl

a tbl.

pattern

pattern to look for. Will be passed to argument pattern to function stringr::str_replace_all().

replacement

a character vector of replacements. Will be passed to argument replacement to function stringr::str_replace_all().

Value

a tbl.

See also

stringr::str_replace_all()

Examples

if (FALSE) { tbl <- tibble::tibble(x = c(letters[1:5] ,letters[1:5] ) , y = c(LETTERS[1:5],LETTERS[1:5]) , z = 1:10 ) tbl %>% tbl_replace_string(pattern = "a" , replacement = "a_changed") tbl %>% tbl_replace_string("[aeiou]", toupper) tbl %>% tbl_replace_string("([aeiou])", "") tbl %>% tbl_replace_string(c("a", "e", "i"), "-") tbl %>% tbl_replace_string("b", NA_character_) }