## set up search terms
searchString.x <- "#HillaryWon" # search term
n.x <- 3000 # number of tweets
radius <- "30mi" # radius around selected geo-location
duration.days <- 1 # how many days
since.date <- (Sys.Date() - duration.days) %>% as.character # calculated starting date
[1] "Using direct authentication"
Get city geo data from maps::cities
Use the twitteR::searchTwitter
command.
n.cities <- 40
Data collection for the top 40 cities (by population) in the U.S. This includes cities from New York to Nashville.
map.plot +
geom_point(aes(x = lon, y = lat, fill = tweet.flux, size = n.tweets), data=analyzed_df, pch=21, color = "#33333399") +
ggtitle(paste0(searchString.x, " tweets in ", duration.days," days since ", since.date, " r = ", radius)) +
scale_fill_gradient(low = "#BBBBFF", high = "#EE3300", space = "Lab", na.value = "grey50", guide = "colourbar")
Here are the top few cities by tweet flux (in “twipermipeds”).
name | tweet.flux | n.tweets | population |
---|---|---|---|
Washington | 39.20 | 239 | 6097684 |
Los Angeles | 19.42 | 259 | 13340068 |
Atlanta | 18.74 | 107 | 5710795 |
Baltimore | 15.73 | 44 | 2797407 |
New York | 9.17 | 185 | 20182305 |
Houston | 6.61 | 44 | 6656947 |
San Diego | 5.76 | 19 | 3299521 |
Denver | 5.69 | 16 | 2814330 |
Chicago | 4.92 | 47 | 9551031 |
Sacramento | 4.84 | 11 | 2274194 |
Las Vegas | 4.73 | 10 | 2114801 |
Charlotte | 4.53 | 11 | 2426363 |
Columbus | 4.45 | 9 | 2021632 |
Austin | 4.00 | 8 | 2000860 |
San Francisco | 3.87 | 18 | 4656132 |
Here are the top few cities sorted by raw tweets, again with major metro areas leading. Note that some other cities, like Chicago, have a large number of tweets but a lower flux because of their higher population.
name | tweet.flux | n.tweets | population |
---|---|---|---|
Los Angeles | 19.42 | 259 | 13340068 |
Washington | 39.20 | 239 | 6097684 |
New York | 9.17 | 185 | 20182305 |
Atlanta | 18.74 | 107 | 5710795 |
Chicago | 4.92 | 47 | 9551031 |
Houston | 6.61 | 44 | 6656947 |
Baltimore | 15.73 | 44 | 2797407 |
Philadelphia | 3.79 | 23 | 6069875 |
San Diego | 5.76 | 19 | 3299521 |
San Francisco | 3.87 | 18 | 4656132 |
Denver | 5.69 | 16 | 2814330 |
Dallas | 1.97 | 14 | 7102796 |
Minneapolis | 3.69 | 13 | 3524583 |
Boston | 2.30 | 11 | 4774321 |
Riverside | 2.45 | 11 | 4489159 |