Search code examples
rfiltertwittersentiment-analysissocial-media

Using a Filter in searchTwitter package in R


I am using the code below to extract tweets with #walmart. I would like 1200 tweets but I want to exclude tweets that have #walmarthelp as a second hashtag.

tweets_a <- searchTwitter("#walmart", n = 1200, lang = "en", since="2020-09-13")

A simple filter after the tweets are extracted will reduce the critical component of n=1200.


Solution

  • Since this uses Twitter's search, the best bet would be using that to your advantage. Twitter allows you to exclude terms using -(minus) within the search query. In your case, "#walmart -#walmarthelp" should exclude the Walmart Help hashtag.