The goal of rtweettree is to recursively scrape a twitter tweet and all replies, quotes, retweets and likes (that the API provides, see here) and visualize them in a network graph. The functionalities to scrape twitter data are heavily based on the excellent rtweet package. The graph network manipulation functionalities rely on the amazing tidygraph package and are visualized with ggraph.
rtweettree should be used in strict accordance with Twitter’s developer terms.
To get the current development version from Github (with the remotes package):
## install dev version of rtweettree from github
remotes::install_github("UrsWilke/rtweettree")
In order to use rtweettree please refer to the according section of rtweet. It is probably good advice to first feel comfortable with rtweet.
First we’ll load the package.
library(rtweettree)
This package can first scrape data related to a twitter status id
main_status_id
(The status id is the last number in the url of every
tweet on twitter.) and all the replies (to replies), quotes, retweets
and likes the API provides (using rtweet
functions under the hood).
main_status_id <- "1438481824922181635"
rtweettree_data_scraped <- rtweettree_data(main_status_id)
This results in a dataframe of rtweet data, which can then be
transformed to a tidygraph::tbl_graph()
object and finally visualized
with ggraph
. When you have loaded the rtweettree package, you can also
directly use the ggplot2::autoplot()
method:
ggplot2::autoplot(rtweettree_data_scraped)
A more in-depth example how to create the subtweet network graph from a
tweet status_id
is shown in the vignette("get_started")
.
If you encounter a bug, please file an issue with a minimal reproducible example on GitHub.