@dataknut
)Just a bit of dataknut fun woven around the day job.
You’ll be wanting Section 6 for the trending hashtags…
CC-BY unless otherwise noted.
See:
The idea is to extract and visualise tweets and re-tweets of #edsclimatechat OR #ccbc18 OR #ccbc2018 (see www.climateandbusiness.com).
Why? Err…. Just. Because.
Code borrows extensively from https://github.com/mkearney/rtweet
The analysis used rtweet
to ask the Twitter search API to extract ‘all’ tweets containing the #edsclimatechat OR #ccbc18 OR #ccbc2018 hashtags in the ‘recent’ twitterVerse.
It is therefore possible that not quite all tweets have been extracted although it seems likely that we have captured most recent human
tweeting which was the main intention. Future work should instead use the Twitter streaming API.
## [1] "Found 8 files matching #edsclimatechat OR #ccbc18 OR #ccbc2018 in ~/Data/twitter/"
The data has:
Figure 5.1 shows the number of tweets and tweeters in the data extract by day. The quotes, tweets and re-tweets have been separated.
If you are in New Zealand and you are wondering why there are no tweets today
(2018-10-12) the answer is that twitter data (and these plots) are working in UTC and (y)our today()
may not have started yet in UTC. Don’t worry, all the tweets are here - it’s just our old friend the timezone… :-)
Next we’ll try by screen name.
Figure 5.2 is a really bad visualisation of all tweeters tweeting over time. Each row of pixels is a tweeter (the names are probably illegible) and a green dot indicates a few tweets in the given day while a red dot indicates a lot of tweets.
So let’s re-do that for the top 50 tweeters so we can see their tweetStreaks (tm)…
Top tweeters:
screen_name | nTweets |
---|---|
AlecTang_ | 83 |
Davidxvx | 61 |
GoodSenseMktg | 57 |
aidselva | 36 |
EDS_Aotearoa | 24 |
KatevP | 24 |
ENVIR_HEALTH | 23 |
E_MSolutions | 21 |
abbie_reynolds | 21 |
anarkaytie | 20 |
SilverLiningGS | 19 |
SustainableAkl | 19 |
DanHikuroa | 19 |
gauloir | 17 |
sustbusiness | 15 |
And their tweetStreaks are shown in Figure 5.3…
Any twitterBots…?
There are a lot of problems with this approach (see Section 7) but Figure 6.1 shows trends over time (watch for lines of apparently dis-similar hashtags where the macron fix has failed) and Figure 6.2 shows the totals to date.
Figure 6.1 uses plotly to avoid having to render a large legend - just hover over the lines to see who is who…
Loads of them. But primarily:
As ever, #YMMV.
Analysis completed in 9.54 seconds ( 0.16 minutes) using knitr in RStudio with R version 3.5.1 (2018-07-02) running on x86_64-apple-darwin15.6.0.
A special mention must go to https://github.com/mkearney/rtweet
(Kearney 2018) for the twitter API interaction functions.
Other R packages used:
Dowle, M, A Srinivasan, T Short, S Lianoglou with contributions from R Saporta, and E Antonyan. 2015. Data.table: Extension of Data.frame. https://CRAN.R-project.org/package=data.table.
Kearney, Michael W. 2018. Rtweet: Collecting Twitter Data. https://cran.r-project.org/package=rtweet.
R Core Team. 2016. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Sievert, Carson, Chris Parmer, Toby Hocking, Scott Chamberlain, Karthik Ram, Marianne Corvellec, and Pedro Despouy. 2016. Plotly: Create Interactive Web Graphics via ’Plotly.js’. https://CRAN.R-project.org/package=plotly.
Wickham, Hadley. 2007. “Reshaping Data with the reshape Package.” Journal of Statistical Software 21 (12): 1–20. http://www.jstatsoft.org/v21/i12/.
———. 2009. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. http://ggplot2.org.
———. 2016. Stringr: Simple, Consistent Wrappers for Common String Operations. https://CRAN.R-project.org/package=stringr.
Wickham, Hadley, Jim Hester, and Romain Francois. 2016. Readr: Read Tabular Data. https://CRAN.R-project.org/package=readr.
Xie, Yihui. 2016a. Bookdown: Authoring Books and Technical Documents with R Markdown. Boca Raton, Florida: Chapman; Hall/CRC. https://github.com/rstudio/bookdown.
———. 2016b. Knitr: A General-Purpose Package for Dynamic Report Generation in R. https://CRAN.R-project.org/package=knitr.
Zhu, Hao. 2018. KableExtra: Construct Complex Table with ’Kable’ and Pipe Syntax. https://CRAN.R-project.org/package=kableExtra.