Skip to content

Instantly share code, notes, and snippets.

@karawoo
Created July 3, 2019 16:34
Show Gist options
  • Save karawoo/729d34b979297aebf2f0a22a9447f420 to your computer and use it in GitHub Desktop.
Save karawoo/729d34b979297aebf2f0a22a9447f420 to your computer and use it in GitHub Desktop.
Follower accession counts for @AMPADPortal
## Follower accession chart for AMPADportal
## Inspired by: https://blog.ouseful.info/2013/04/05/estimated-follower-accession-charts-for-twitter/
library("rtweet")
library("tidyverse")
followers <- get_followers("AMPADPortal")
followers_df <- lookup_users(followers$user_id)
process_user_data <- function(data) {
data %>%
rowid_to_column("id") %>%
mutate(
days = as.numeric(
difftime(Sys.time(), account_created_at, units = "days")
)
) %>%
arrange(-id) %>%
rowid_to_column("acc") %>%
mutate(recency = cummin(days))
}
dat <- process_user_data(followers_df)
ggplot(dat) +
geom_point(aes(x = -days, y = acc)) +
geom_line(aes(x = -recency, y = acc), col = "red") +
labs(
x = "account creation date (days)",
y = "accession",
title = "@AMPADPortal follower accession"
) +
scale_x_continuous(breaks = seq(0, -5000, by = -250)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment