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.
This exercise is part of the course
Text Mining with Bag-of-Words in R
Exercise instructions
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
withdecreasing = TRUE
. Save assorted_chardonnay_words
. - Look at the top 6 words in
sorted_chardonnay_words
and their values. - Create
terms_vec
usingnames()
onchardonnay_words
. - Pass
terms_vec
andchardonnay_words
into thewordcloud()
function. Review what other words pop out now that "chardonnay" is removed.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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")