Exercise

Word impact, frequency analysis

One of the easiest ways to explore data is with a frequency analysis. Although not difficult, in sentiment analysis this simple method can be surprisingly illuminating. Specifically, you will build a barplot. In this exercise you are once again working with moby and bing to construct your visual.

To get the bars ordered from lowest to highest, you will use a trick with factors. reorder() lets you change the order of factor levels based upon another scoring variable. In this case, you will reorder the factor variable term by the scoring variable polarity.

Instructions 1/3

undefined XP
    1
    2
    3
  • Create moby_tidy_sentiment.
    • Use count() with term, sentiment, and wt = count.
    • Pipe to pivot_wider() with names_from = sentiment, values_from = n, and values_fill = 0
    • Pipe to mutate(). Call the new variable polarity; calculated as positive minus negative.
  • Call moby_tidy_sentiment to review and compare it to the previous exercise.