Home > Back-end >  Multiple patterns and replacements from "dictionary" dataframe in R, maybe with gsub?
Multiple patterns and replacements from "dictionary" dataframe in R, maybe with gsub?

Time:11-14

I have a dataset with strings (data$text) containing names of emojis instead of actual images (e.g., FACE_WITH_TEARS_OF_JOY). Now I'm trying to replace each emoji name with the actual emoji. The names and emojis are saved in an extra dataset which works as "dictionary" (emojis$name and emojis$emoji).

For a single emoji this code works:

data$text <- gsub("FACE_WITH_TEARS_OF_JOY", "           
  • Related