trinker / sentimentr

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

plot.sentiment_by ordered fix? #133

Open edmundseto opened 1 year ago

edmundseto commented 1 year ago

Great package! I appreciate your work on this.

When plotting a sentiment_by result, I noticed that it always orders groups by the median sentiment regardless of if I set the ordered parameter TRUE or FALSE.

I looked at the code for the plotting plot.sentiment_by on github and it doesn't seem like the ordered parameter is used.

I'm not sure, but I suggest this as potential fix in that function:

    if (ordered==TRUE) {
      x[, grouping.vars := factor(grouping.vars, levels = rev(grouping.vars))]
    } else {
      x[, grouping.vars := factor(grouping.vars)]
    }

Best, Edmund