Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x <- gsub("'", "", x)
- x <- gsub(" ", "_", x)
- x <- chartr("' ", "_", x)
- #Error in chartr("' ", "_", "a'b c") : 'old' is longer than 'new'
- library(gsubfn)
- gsubfn(".", list("'" = "", " " = "_"), x)
- # [1] "ab_c"
- library(magrittr)
- x <- "a'b c"
- x %<>%
- gsub("'", "", .) %>%
- gsub(" ", "_", .)
- x
- ##[1] "ab_c"
- gsub("\s", "", chartr("' ", " _", x)) # Use whitespace and then remove it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement