Last active
April 14, 2022 15:56
-
-
Save knbknb/9c98486ca699236837addd466fcd66eb to your computer and use it in GitHub Desktop.
search for 100000 tweets using the rstats hashtag '#relotius'
This file contains hidden or 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
## The Claas Relotius Scandal just happened to be a popular/interesting topic | |
## in the German news when I develeoped this code. | |
## (Relotius was/is a cheating journalist who made up his own stories | |
## to gain prizes and fame) | |
## Lots of people have tweeted about the story in 2018. | |
library(rtweet) | |
## search for 18000 tweets using the rstats hashtag | |
rt <- search_tweets( | |
"#relotius", n = 100000, include_rts = FALSE | |
) | |
## preview tweets data | |
rt | |
## preview users data | |
users_data(rt) | |
## plot time series (if ggplot2 is installed) | |
ts_plot(rt) + | |
ggtitle("#relotius hashtag", | |
subtitle = "On Twitter, in Dec. 2018, n= 17000 Tweets, no retweets" | |
) | |
## plot time series of tweets | |
ts_plot(rt, "3 hours") + | |
ggplot2::theme_minimal() + | |
ggplot2::theme(plot.title = ggplot2::element_text(face = "bold")) + | |
ggplot2::ylim(0, 700) + | |
ggplot2::labs( | |
x = NULL, y = NULL, | |
title = "Frequency of #relotius Twitter statuses in Dec 2018", | |
subtitle = "Tweet counts aggregated using three-hour intervals; no retweets.", | |
caption = "\nSource: Data collected from Twitter's REST API via rtweet") | |
Filter output with jq
Users with "Berlin" in their description; one line per entry, only
`< stream__relotius.json jq -c -r 'select (.user.location == "Berlin")| [ "https://twitter.com/" +.user.screen_name, .user.name, .user.description] | @csv ' | sort -u
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
date: 2018-12-30; Output: 1 plot,