Last active
March 4, 2020 03:07
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("rtweet") # Load rtweet | |
library("httpuv") # Authenticate without Twitter Developer account | |
library("tidyverse") # Load tidyverse for ggplot and magrittr | |
library("scales") # Customize axes | |
trends_avail <- trends_available() # Check locales | |
dc_trends <- get_trends("washington") # Set to Washington DC | |
dc_trends %>% | |
subset(!is.na(tweet_volume) & tweet_volume >= 50000) %>% # Remove NA and low volume trends | |
ggplot() + | |
geom_bar(mapping = aes(x = reorder(trend, -tweet_volume), y = tweet_volume), stat = "identity") + | |
scale_y_continuous(labels = comma) + | |
theme(axis.title.x = element_blank()) + | |
labs(title = "Washington DC Twitter Trends", | |
caption = "\nSource: Data collected via rtweet - graphic by @mjhendrickson") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get Twitter trends from the DC area via rtweet