Using rtweet and ggplot2 to plot twitter words frequencies
This section seeks the master for words of wisdom. We're about to scrap Hadley's twitter (@hadleywickham
). Several packages are combined in order to bring achieve the upcoming visual. This recipe begins by doing the twitter scrap, filtering data and finally plotting it with ggplot2
.
Getting ready...
Besides ggplot2
there are four packages we require for this recipe. All of them can be downloaded and installed by the following code:
> if(!require(rtweet)){ install.packages('rtweet')} > if(!require(rcorpora)){ install.packages('rcorpora')} > if(!require(dplyr)){ install.packages('dplyr')} > if(!require(tidytext)){ install.packages('tidytext')}
With the right tools (packages) the task can be easily handled.
How to do it...
Let us see how to use <kbd>rtweet and ggplot2
to plot twitter words frequencies
- Scrap tweets from Hadley's time line with
rtweet::get_timeline()
:
> library(rtweet) > sept_2017 <- '907969109840756736...