0

I am working on sentiments and would like to replace the emoticons with words expressing the mood of the emoticon using qdap in R.

Can someone help me how to do it. I will further use the output to get the overall sentiment of the text.

Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519

2 Answers2

2

Something like this would work:

text <- "I like :) chicken but not beef :("

library(qdapDictionaries)
mgsub(as.character(emoticon[[2]]), as.character(emoticon[[1]]), text)

## "I like Smile chicken but not beef Sad"
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
  • PS the columns in the `emoticon` dictionary are stored as factor. This has been changed to character in the del version and once it goes to CRAN `as.character` will not be needed. – Tyler Rinker Jan 12 '15 at 22:15
0

If I am understanding you correctly and you are talking about plain emoticons, you can just do a pattern match and replace

R>  text = c(":)", ":(")
R> gsub(":)", "happy", text)
[1] "happy" ":(" 
Stedy
  • 7,359
  • 14
  • 57
  • 77