You want chartr
:
df$var1 <- chartr("abcdef", "hijklm", df$var1)
df
# var1
# 1 hhiijklmg
# 2 hhiijklmg
More Related Contents:
- Replace multiple letters with accents with gsub
- Replace specific characters within strings
- Remove everything after space in string
- gsub() in R is not replacing ‘.’ (dot)
- in R, use gsub to remove all punctuation except period
- How to remove unicode from string?
- Remove all punctuation except apostrophes in R
- Selecting data frame rows based on partial string match in a column
- How to use grep()/gsub() to find exact match
- How to remove all whitespace from a string?
- Using regex in R to find strings as whole words (but not strings as part of words)
- Test if characters are in a string
- Remove parentheses and text within from strings in R
- POSIX character class does not work in base R regex
- R – gsub replacing backslashes
- Select columns based on string match – dplyr::select
- Use grepl to search either of multiple substrings in a text [duplicate]
- select columns based on multiple strings with dplyr contains()
- Remove pattern from string with gsub
- Remove parenthesis from a character string
- Check if string contains ONLY NUMBERS or ONLY CHARACTERS (R)
- Regex return file name, remove path and file extension
- pivot_longer into multiple columns
- Remove part of a string in dataframe column (R)
- Replace first occurrence of “:” but not second in R
- “‘\w’ is an unrecognized escape” in grep
- How to extract substring between patterns “_” and “.” in R [duplicate]
- How to strsplit using ‘|’ character, it behaves unexpectedly?
- How to grep a word exactly
- remove text after final period in string