Search code examples
rtwitterrjson

Removing text tweets from dataset in R


I am working on twitter dataset, I need to remove some tweets concerning a certain word. I have retrieved the tweets concerning this word and I saved those tweets in a variable called "removing". I need now to remove those tweets from my dataset, would anyone tell me how I can solve it?

Snippet of data link and here is the code:

 library(streamR)
 library(rjson)
 library(wordcloud)
 library(tm)
 tweets = parseTweets("tweets.json")
 table(tweets$created_at)
 table(tweets$text)
 removing <- tweets$text[grep("The text tweet I want to
 remove",tweets$text,ignore.case=T)]     

Solution

  • Use grepl to return TRUE FALSE from a grep string...

    tweets <- subset(tweets, !grepl("The text tweet I want to remove", tweets$text))