Skip to content

Instantly share code, notes, and snippets.

@knbknb
Last active April 14, 2022 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knbknb/9c98486ca699236837addd466fcd66eb to your computer and use it in GitHub Desktop.
Save knbknb/9c98486ca699236837addd466fcd66eb to your computer and use it in GitHub Desktop.
search for 100000 tweets using the rstats hashtag '#relotius'
## 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")
@knbknb
Copy link
Author

knbknb commented Dec 30, 2018

date: 2018-12-30; Output: 1 plot,

rplot-relotius-20181230
rplot-relotius-2019

@knbknb
Copy link
Author

knbknb commented Jan 19, 2019

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