Build Status Build status codecov.io Coverage Status CRAN_Status_Badge CRAN log

GraphTweets

gephi.gif
gephi.gif

Visualise networks of Twitter interactions.

Updated the package to better suit rtweets

Install

install.packages("graphTweets") # CRAN release v0.4
devtools::install_github("JohnCoene/graphTweets") # dev version

Documentation

Features

v4

See NEWS.md for changes.

Rationale

Functions are meant to be run in a specific order.

  1. Extract edges
  2. Extract the nodes

One can only know the nodes of a network based on the edges, so run them in that order. However, you can build a graph based on edges alone:

tweets %>% 
  gt_edges(text, screen_name) %>% 
  gt_graph() %>% 
  plot(., vertex.size = igraph::degree(.) * 10)

This is useful if you are building a large graph and don’t need any meta data on the nodes (other than those you can compute from the graph, i.e.: degree like in the example above). If you need meta data on the nodes use gt_nodes.

tweets %>% 
  gt_edges(text, screen_name) %>% 
  gt_nodes(meta = TRUE) %>% # set meta to TRUE
  gt_graph() %>% 
  plot(., vertex.size = v(.)$followers_count) # size nodes by follower count.

Examples

v4

library(rtweet)

# Sys.setlocale("LC_TIME", "English")

tweets <- search_tweets("#rstats")

library(graphTweets)

# simple network
tweets %>% 
  gt_edges(text, screen_name) %>% # get edges
  gt_nodes %>% # get nodes
  gt_graph %>% # build igraph object
  plot(.)

# dynamic graph
tweets %>% 
  gt_edges(text, screen_name, "created_at") %>% # add created time
  gt_nodes(TRUE) %>%
  gt_dyn %>% # make dynamic
  gt_save # save as .graphml