0
votes

I am trying to perform sentiment analysis on a twitter data set. For that I am using few positive and negative dictionaries. What I want is that for below tweet

The movie intersteller was insanely awesome

Positive Dictionary: Good 2 awesome 5

Negative Dictionary: bad -2 insanely -3

So the score of the tweet should be = -3 (insanely) + 5(awesome) = 2

I have been able to match my dataset against these dictionary to create a posMatch variable which looks like below: posMatches <- match(words, afinn_list$word)

posMatches NA NA NA NA 1104 NA NA NA NA NA NA NA NA NA NA NA NA 1836 NA Now I know which location contains a match. I need help to sum of weigts of say location 1104 and 1836 in above example

1

1 Answers

1
votes

What you need is to sum over your posMatches not considering NAs:

 sum(posMatches, na.rm = TRUE)