knitr::opts_chunk$set(cache = TRUE)
library(twitterreport)
data("senators_profile")
data("senate_tweets")
data("senators")
Definition list
Is something people use sometimes.
Markdown in HTML
Does *not* work **very** well. Use HTML tags.

General stats

Most popular #hashtags

This graph shows the 5 most popular hashtags in this network through time including the number of times that these were mentioned in total (the table includes more).

# Creating stats (and data)
elements <- tw_extract(senate_tweets$text)

# Graph
hashtags <- tw_timeseries(elements$hashtag,created_at = senate_tweets$created_at)
plot(hashtags)

# Table
twtab <- tw_table(elements, "hashtag")
plot(twtab,caption='Most popular hashtags')

Most popular @users

This graph shows the set of 5 of the most popular users. Just like the previous stats, while the graph shows the number of mentions through time, the table shows the total number of mentions.

# Graph
mentions <- tw_timeseries(elements$mention,created_at = senate_tweets$created_at)
plot(mentions)

# Creating table for users
plot(tw_table(elements, "mention"),caption='Most popular users')

Mention Networks

This is the graph of conversations between US senators. Colored by party (light blue are democrats, blue are republicans and orange is independent), the thickness of the edges (links) represent the number of times that one senator mentions the other. Notice that interestingly Democrats and Republicans tend to group around while Sen. Angus King (only independent in the graph) is right in between the two groups.

In this case I consider two senators connected iff there one of them appears at least 3 times in the other senator's status timeline.

tweets_components <- tw_extract(senate_tweets$text)
groups <- data.frame(
  name      = senators_profile$tw_screen_name,
  group     = factor(senators$party),
  real_name = senators$Name,
  stringsAsFactors = FALSE)
groups$name <- tolower(groups$name)

senate_network <- tw_network(
  tolower(senate_tweets$screen_name),
  lapply(tweets_components$mention,unique),only.from = TRUE,
  group=groups, min.interact = 3)

plot(senate_network, nodelabel='real_name')

Word cloud

What are the senators talking about

plot(tw_words(senate_tweets$text))


gvegayon/twitterreport documentation built on May 17, 2019, 9:30 a.m.