Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Sat Oct 5 10:06:01 2019 ------------------------------
# Bonus - rm bots, time-dependend wordclouds & sentiment analysis
rtStats <- do.call("rbind", by(allTweets, INDICES = allTweets$screen_name, function(x){
return(data.frame(num_tweets = nrow(x),
mean_followers = mean(x$followers_count),
median_rt = median(x$retweet_count)))
}))
# Plot log10(num_tweets) vs. log10(median_rt)
with(log10(rtStats+1), plot(num_tweets, median_rt,
cex = mean_followers / max(mean_followers),
pch = 16,
col = rgb(0,0,0,.25),
xlab = expression(paste(log[10], " # tweets + 1")),
ylab = expression(paste(log[10], " median # rts + 1"))))
nums <- c(1e2, 1e4, 1e6, 1e8)
legend("topright", title = "# followers",
pch = 16, col = rgb(0,0,0,.25),
pt.cex = log10(nums + 1)/max(log10(rtStats$mean_followers + 1)),
legend = formatC(nums, format = "e", digits = 1),
bty = "n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment