tbl_replace_string: Wrapper around 'stringr::str_replace_all()'

Description Usage Arguments Value See Also Examples

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
 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_)


## End(Not run)

cparsania/TidyWrappers documentation built on Feb. 6, 2022, 3:25 p.m.