Created
July 20, 2018 16:15
-
-
Save wesslen/72716aa74b5f558215de0c61e64de6fa to your computer and use it in GitHub Desktop.
combine multiple rtweet streams
This file contains hidden or 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) | |
| library(dplyr) | |
| files <- list.files() | |
| files <- files[grep(".json", files)] | |
| getPoints <- function(file){ | |
| parse_stream(file) %>% | |
| lat_lng("bbox_coords") %>% # keep bounding box coords | |
| filter(is_retweet == FALSE & !is.na(lat)) %>% # keep posts and point lat/longs | |
| select(status_id, created_at, screen_name, text, is_retweet, lat, lng) # whatever columns to select | |
| } | |
| df <- purrr::map_df(files, getPoints) | |
| ## plot state boundaries | |
| par(mar = c(0, 0, 0, 0)) | |
| maps::map("state", lwd = .25) | |
| ## plot lat and lng points onto state map | |
| with(df, points(lng, lat, pch = 20, cex = .75, col = rgb(0, .3, .7, .75))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment