0

I'm conducting sentiment analysis and I have a dataframe that has the following structure

Text <- c("Text A", "Text A", "Text B", "Text B", "Text B", "Text C", "Text C", "Text C", "Text C")
emotion <- c("joy", "Surprise", "fear", "disgust", "anger", "fear", "anticipation", "joy", "sadness")
sentiment <- c("positive", "positive", "negative", "negative", "negative", "negative", "positive","positive",  "negative")
sentimentscore <- c(23, 21, -22, -10, -3, -10, 15, 3, -7)

sentiDF <- data.frame(Text, emotion, sentiment, sentimentscore)


> sentiDF
    Text      emotion sentiment sentimentscore
1 Text A          joy  positive             23
2 Text A     Surprise  positive             21
3 Text B         fear  negative            -22
4 Text B      disgust  negative            -10
5 Text B        anger  negative             -3
6 Text C         fear  negative            -10
7 Text C anticipation  positive             15
8 Text C          joy  positive              3
9 Text C      sadness  negative             -7

I want to apply a filter whereby I remain with Unique observations under Text column that have either the highest positive or negative sentimentscore while keeping all other columns.

How do I go about that?

andy
  • 1,947
  • 5
  • 27
  • 46

0 Answers0