ComeçarComece de graça

A simple word cloud

At this point, you have had too much coffee. Plus, seeing the top words such as "shop", "morning", and "drinking" among others just isn't all that insightful.

In celebration of making it this far, let's try our hand on another batch of 1000 tweets. For now, you won't know what they have in common, but let's see if you can figure it out using a word cloud. The tweets' term frequency values are preloaded in your workspace.

A word cloud is a visualization of terms. In a word cloud, size is often scaled to frequency, and in some cases, the colors may indicate another measurement. For now, we're keeping it simple: size is related to individual word frequency, and we are just selecting a single color.

As you saw in the video, the wordcloud() function works like this:

wordcloud(words, frequencies, max.words = 500, colors = "blue")

Text mining analyses often include simple word clouds. In fact, they are probably overused, but can still be useful for quickly understanding a body of text!

term_frequency is loaded into your workspace.

Este exercício faz parte do curso

Text Mining with Bag-of-Words in R

Ver curso

Instruções do exercício

  • Load the wordcloud package.
  • Print out first 10 entries in term_frequency.
  • Extract the terms using names() on term_frequency. Call the vector of strings terms_vec.
  • Create a wordcloud() using terms_vec as the words, and term_frequency as the values. Add the parameters max.words = 50 and colors = "red".

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Load wordcloud package


# Print the first 10 entries in term_frequency


# Vector of terms


# Create a word cloud for the values in word_freqs
Editar e executar o código