Kom igångKom igång gratis

Plot the better word cloud

Now that you've removed additional stopwords let's take a look at the improved word cloud!

The term-document matrix from the previous exercise has been turned into matrix with as.matrix(), then a named vector was created with rowSums(). This new object of term frequencies called chardonnay_words is preloaded into your workspace. Let's take a look at these new word cloud results.

Den här övningen är en del av kursen

Text Mining with Bag-of-Words in R

Visa kurs

Övningsinstruktioner

We've loaded the wordcloud package for you behind the scenes and will do so for all additional exercises requiring it.

  • Sort the values in chardonnay_words with decreasing = TRUE. Save as sorted_chardonnay_words.
  • Look at the top 6 words in sorted_chardonnay_words and their values.
  • Create terms_vec using names() on chardonnay_words.
  • Pass terms_vec and chardonnay_words into the wordcloud() function. Review what other words pop out now that "chardonnay" is removed.

Interaktiv övning med praktiskt arbete

Testa den här övningen genom att slutföra den här exempelkoden.

# Sort the chardonnay_words in descending order
___ <- ___(___, ___)

# Print the 6 most frequent chardonnay terms
___(___)

# Get a terms vector
___ <- ___(___)

# Create a wordcloud for the values in word_freqs
wordcloud(___, ___, 
          max.words = 50, colors = "red")
Redigera och kör kod