Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. library(twitteR)
  2. library(ggplot2)
  3. library(dplyr)
  4. library(tidyr)
  5. library(ggthemes)
  6.  
  7. # this function from the twitteR package have a hardcoded search for #rstats
  8. # to search for something different use searchTwitter("topic")
  9. r_tweets <- Rtweets(n=5000,retryOnRateLimit=5000,resultType="recent")
  10.  
  11. r_tweets <- r_tweets %>% twListToDF() %>% tbl_df()
  12.  
  13. users_lookup <- lookupUsers(unique(r_tweets$screenName))
  14. users_lookup <- rbindlist(lapply(users_lookup,as.data.frame))
  15.  
  16. geotag <- users_lookup$location %>% na.omit() %>% geocode(source="dsk") %>% na.omit()
  17.  
  18. mapWorld <- borders("world", colour="gray60", fill="gray60")
  19.  
  20. world_r <- ggplot() +
  21. mapWorld +
  22. geom_point(data=geotag,aes(lon,lat),color="#00aced",alpha=0.5,size=3) +theme_tufte() +
  23. theme( axis.text.x=element_blank(),
  24. axis.text.y=element_blank(),
  25. axis.ticks=element_blank(),
  26. axis.title.x=element_blank(),
  27. axis.title.y=element_blank(),
  28. plot.title=element_text(face = "bold")) +
  29. ggtitle("The world of #rstats in the last 4K tweets.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement