## Not run:
# ## stream tweets mentioning beibs and tswift for 10 mins
# rt <- rtweet::stream_tweets(
# q = "justinbieber,taylorswift13",
# timeout = (60 * 60 * 10))
#
# ## split mentions into distinct elements
# mentions <- strsplit(rt$mentions_screen_name, ",")
#
# ## sorted table of mentions
# mentions <- sort(table(unlist(mentions)),
# decreasing = TRUE)
#
# ## exclude biebs and tswift
# mentions <- grep("justinbieber|taylorswift13", names(mentions),
# invert = TRUE, value = TRUE)
#
# ## store next most pop in obj
# thirdpop <- mentions[1]
#
# ##plot with mentions as filters
# ts.df <- ts_plot(rt, by = "mins", filter = c(
# "justinbieber", "taylorswift", thirdpop),
# main = "Biebs vs Tswift")
#
# ## preview returned data frame
# head(ts.df)
#
# ## End(Not run)
Run the code above in your browser using DataLab