Skip to content

Instantly share code, notes, and snippets.

@jebyrnes
Created January 15, 2020 17:32
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 jebyrnes/7d9519588ce8ef08f7e8f78ef11ad417 to your computer and use it in GitHub Desktop.
Save jebyrnes/7d9519588ce8ef08f7e8f78ef11ad417 to your computer and use it in GitHub Desktop.
#note, above this, use rtweet
#instructions for getting api keys and the like
#from http://dev.twitter.com
library(rtweet)
library(tweetbotornot)
library(ggplot2)
library(dplyr)
library(ggridges)
token <- create_token(
app = "byrnesTweetAnalysis",
consumer_key = api_key,
consumer_secret = api_secret_key,
access_token = access_token,
access_secret = access_secret)
## search for 18000 tweets using the rstats hashtag
nw_tweets<- search_tweets(
"#neverWarren", n = 20, include_rts = FALSE
)
#assess the unique users for bot-ness
bots <- tweetbotornot(unique(nw_tweets$screen_name))
bots <- bots %>%
mutate(half_bot = ifelse(prob_bot>0.5, "Likely Bot", "Unlikely Bot"))
#plot the distribution - huh, it's bimodal
ggplot(data = bots,
aes(x = prob_bot)) +
geom_density(fill = "lightblue", alpha = 0.5)
#split at 0.5 and see what the dists look like
ggplot(data = bots,
aes(x = prob_bot, y = half_bot, fill = half_bot)) +
geom_density_ridges() +
theme_bw(base_size=14)
#numbers of users that fall above or below 50% threshold
ggplot(data = bots,
aes(x = half_bot, fill = half_bot)) +
geom_bar() +
theme_bw(base_size=14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment