# NOT RUN {
# }
# NOT RUN {
## search for 1000 tweets mentioning Hillary Clinton
hrc <- search_tweets(q = "hillaryclinton", n = 1000)
## data frame where each observation (row) is a different tweet
hrc
## users data also retrieved. can access it via users_data()
users_data(hrc)
## search for 1000 tweets in English
djt <- search_tweets(q = "realdonaldtrump", n = 1000, lang = "en")
## preview tweets data
djt
## preview users data
users_data(djt)
## exclude retweets
rt <- search_tweets("rstats", n = 500, include_rts = FALSE)
## perform search for lots of tweets
rt <- search_tweets(
"trump OR president OR potus", n = 100000,
retryonratelimit = TRUE
)
## plot time series of tweets frequency
ts_plot(rt, by = "mins")
## make multiple independent search queries
ds <- Map(
"search_tweets",
c("\"data science\"", "rstats OR python"),
n = 1000
)
## bind by row whilst preserving users data
ds <- do_call_rbind(ds)
## preview tweets data
ds
## preview users data
users_data(ds)
# }
# NOT RUN {
# }
# NOT RUN {
## search using multilple queries
st2 <- search_tweets2(
c("\"data science\"", "rstats OR python"),
n = 500
)
## preview tweets data
st2
## preview users data
users_data(st2)
## check breakdown of results by search query
table(st2$query)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab