Simple Wordcloud wordclouds
A wordcloud can be one of the best tools that allows us to visualize most of the words and terms contained in tweets. Although its main use is for exploratory purposes, they have the advantage to be understandable by most users, and to be visually attractive to the human eyes (if done adequately).
How to create a wordcloud?
Wordclouds are relatively simple to make. Here's the main recipe steps
Download some tweets (via twitteR or XML)
Extract the text from the tweets
Do some text manipulation (for cleaning & formatting)
Create a lexical Corpus and a TermDocumentMatrix (via tm)
Obtain words and their frequencies
Plot the wordcloud
Example 1: tweets via twitteR
Step 1: Load all the required packages
Step 2: Let's get some tweets in english containing the words "machine learning"
Step 3: Extract the text from the tweets in a vector
Step 4: Construct the lexical Corpus and the Term Document Matrix
We use the function Corpus to create the corpus, and the function VectorSource to indicate that the text is in the character vector mach_text. In order to create the term-document matrix we apply different transformation such as removing numbers, punctuation symbols, lower case, etc.
Step 5: Obtain words and their frequencies
Step 6: Let's plot the wordcloud
© Gaston Sanchez - 2012