I am trying to replace the parts of string by several matching expressions. I have found how to apply the str_replace_all on the specific column. But I do not know how to apply it within the dataframe with the dplyr piping?
Dummy example:
d <- data.frame(nam = c('aaa_string', 'bb_salala', 'cc_bububub'))
# applied on the d$nam vector every thing is working
d$nam %>%
str_replace_all(c("aaa" = "1", "bb" = "2", "cc" = "33"))
Using the same statement within the mutate it suddenly does not work, claiming that argument "pattern" is missing in str_replace_all. How to fix it?
Expected output:
nam
"1_string"
"2_salala"
"33_bububub"