trinker / sentimentr

Dictionary based sentiment analysis that considers valence shifters
Other
427 stars 84 forks source link

Bug in plot.sentiment when sentiment made by get_sentence.data.frame #90

Closed trinker closed 6 years ago

trinker commented 6 years ago
dat <- data.frame(
    w = c('Person 1', 'Person 2'),
    x = c(paste0(
        "Mr. Brown is nasty! He says hello. i give him rage.  i will ",
        "go at 5 p. m. eastern time.  Angry thought in between!go there"
    ), "One more thought for the road! I am going now.  Good day and good riddance."),
    y = state.name[c(32, 38)], 
    z = c(.456, .124),
    stringsAsFactors = FALSE
)

plot(sentiment(get_sentences(dat)))

Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In data.matrix(x) : NAs introduced by coercion
2: In data.matrix(x) : NAs introduced by coercion
3: In data.matrix(x) : NAs introduced by coercion
4: In min(x) : no non-missing arguments to min; returning Inf
5: In max(x) : no non-missing arguments to max; returning -Inf
6: In min(x) : no non-missing arguments to min; returning Inf
7: In max(x) : no non-missing arguments to max; returning -Inf
> 

## works fine
plot(sentiment(dat$x))
trinker commented 6 years ago

I suspect this is because all of the data.frame is assigned to sentences in the return class rather than just the text vector. We'll need to detect this and assign only the text .variable