Guest User

Untitled

a guest
Jul 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. library(rtweet)
  2. library(dplyr)
  3.  
  4. files <- list.files()
  5. files <- files[grep(".json", files)]
  6.  
  7. getPoints <- function(file){
  8. parse_stream(file) %>%
  9. lat_lng("bbox_coords") %>% # keep bounding box coords
  10. filter(is_retweet == FALSE & !is.na(lat)) %>% # keep posts and point lat/longs
  11. select(status_id, created_at, screen_name, text, is_retweet, lat, lng) # whatever columns to select
  12. }
  13.  
  14. df <- purrr::map_df(files, getPoints)
  15.  
  16. ## plot state boundaries
  17. par(mar = c(0, 0, 0, 0))
  18. maps::map("state", lwd = .25)
  19.  
  20. ## plot lat and lng points onto state map
  21. with(df, points(lng, lat, pch = 20, cex = .75, col = rgb(0, .3, .7, .75)))
Add Comment
Please, Sign In to add comment