Replace all occurance of 'pattern'
in all non numeric columns from a tbl.
tbl_replace_string(tbl, pattern, replacement)
tbl | a tbl. |
---|---|
pattern | pattern to look for. Will be passed to argument |
replacement | a character vector of replacements. Will be passed to argument |
a tbl.
stringr::str_replace_all()
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_) }