Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(twitteR)
- library(ggplot2)
- library(dplyr)
- library(tidyr)
- library(ggthemes)
- # this function from the twitteR package have a hardcoded search for #rstats
- # to search for something different use searchTwitter("topic")
- r_tweets <- Rtweets(n=5000,retryOnRateLimit=5000,resultType="recent")
- r_tweets <- r_tweets %>% twListToDF() %>% tbl_df()
- users_lookup <- lookupUsers(unique(r_tweets$screenName))
- users_lookup <- rbindlist(lapply(users_lookup,as.data.frame))
- geotag <- users_lookup$location %>% na.omit() %>% geocode(source="dsk") %>% na.omit()
- mapWorld <- borders("world", colour="gray60", fill="gray60")
- world_r <- ggplot() +
- mapWorld +
- geom_point(data=geotag,aes(lon,lat),color="#00aced",alpha=0.5,size=3) +theme_tufte() +
- theme( axis.text.x=element_blank(),
- axis.text.y=element_blank(),
- axis.ticks=element_blank(),
- axis.title.x=element_blank(),
- axis.title.y=element_blank(),
- plot.title=element_text(face = "bold")) +
- ggtitle("The world of #rstats in the last 4K tweets.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement