Last active
May 23, 2018 22:38
-
-
Save mjhendrickson/bf85e176dbb387231d65880036d66097 to your computer and use it in GitHub Desktop.
Exploration of rtweet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----- Load libraries ----- | |
library("rtweet") | |
library("devtools") | |
library("tidyverse") | |
library("gridExtra") | |
# ----- Connection data (removed) ----- | |
appname <- "" # name of twitter app | |
key <- "" # api key | |
secret <- "" # api secret | |
token <- create_token( | |
app = appname, | |
consumer_key = key, | |
consumer_secret = secret) | |
# ----- Tweets from R4DScommunity ----- | |
r4ds <- get_timeline(c("R4DScommunity"), n = 5000) | |
# Plot frequency of tweets for R4DScommunity | |
r4ds_plot <- | |
r4ds %>% | |
filter(created_at > "2018-04-14") %>% | |
ts_plot("days", trim = 1L) + | |
geom_point() + | |
theme_minimal() + | |
theme( | |
legend.title = element_blank(), | |
legend.position = "bottom", | |
plot.title = element_text(face = "bold")) + | |
labs( | |
x = NULL, | |
y = NULL, | |
title = "Frequency of @R4DScommunity Twitter Statuses", | |
subtitle = "Tweet counts by day since @R4DScommunity's first tweet (April 14, 2018", | |
caption = "\nSource: Data collected via rtweet - graphic by @mjhendrickson" | |
) | |
# ----- Tweets from mjhendrickson ----- | |
mh <- get_timeline(c("mjhendrickson"), n = 5000) | |
# Plot frequency of tweets for mjhendrickson | |
mh_plot <- | |
mh %>% | |
filter(created_at > "2018-04-14") %>% | |
ts_plot("days", trim = 1L) + | |
geom_point() + | |
theme_minimal() + | |
theme( | |
legend.title = element_blank(), | |
legend.position = "bottom", | |
plot.title = element_text(face = "bold")) + | |
labs( | |
x = NULL, | |
y = NULL, | |
title = "Frequency of @mjhendrickson Twitter Statuses", | |
subtitle = "Tweet counts by day since April 14, 2018", | |
caption = "\nSource: Data collected via rtweet - graphic by @mjhendrickson" | |
) | |
# Plot together | |
grid.arrange(r4ds_plot, mh_plot) |
Author
mjhendrickson
commented
May 21, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment