Skip to content

Instantly share code, notes, and snippets.

@wesslen
Created February 20, 2018 21:30
Show Gist options
  • Select an option

  • Save wesslen/b38c938bac06ee6eb173d3c450b70ccc to your computer and use it in GitHub Desktop.

Select an option

Save wesslen/b38c938bac06ee6eb173d3c450b70ccc to your computer and use it in GitHub Desktop.
twitter trolls
library(tidyverse); library(lubridate)
url <- "http://nodeassets.nbcnews.com/russian-twitter-trolls/tweets.csv"
tweets <- read_csv(url)
user.url <- "http://nodeassets.nbcnews.com/russian-twitter-trolls/users.csv"
users <- read_csv(user.url)
tweets %>%
count(Date = as.Date(created_str)) %>%
ggplot(aes(x = Date, y = n)) +
geom_line() +
labs(title = "Tweets by Known Twitter Trolls",
x = "Day",
y = "Number of Tweets")
library(tidytext)
top10 <- tweets %>%
count(user_key, sort = TRUE) %>%
head(n = 10)
tweets %>%
filter(user_key %in% top10$user_key) %>%
count(Date = as.Date(created_str), ScreenName = user_key) %>%
ggplot(aes(x = Date, y = n)) +
geom_line() +
facet_wrap(~ScreenName, ncol=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment