Skip to content

Instantly share code, notes, and snippets.

@geoffjentry
Last active March 2, 2021 06:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geoffjentry/8226180 to your computer and use it in GitHub Desktop.
Save geoffjentry/8226180 to your computer and use it in GitHub Desktop.
Remove retweets
load("code2013.rda")
# Find/remove the tweets flagged as retweets
is_retweets = which(sapply(code2013, function(x) x$getIsRetweet()))
if (length(is_retweets) > 0) {
filtered_tweets = code2013[-is_retweets]
} else {
filtered_tweets = code2013
}
statuses = sapply(filtered_tweets, function(x) x$getText())
# Find and remove RT based retweets. This will be overeager but we're not losing many
# tweets anyways
manual_retweets = grep("[[:space:]]?rt", statuses)
if (length(manual_retweets) > 0) {
filtered_tweets = filtered_tweets[-manual_retweets]
statuses = statuses[-manual_retweets]
}
@Nikunj-Goyal
Copy link

this is no longer work. can u make a new version? i need this

https://gist.github.com/FocusWho/5a8e74895293eae0071cec612477c72f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment