Search code examples
rrtweet

Use boolean in streem_tweet request rtweet


Hello every one I would like if and how it's possible to use boolean in the function stream_tweet of the rtweet package. It dosnt seemz to work like in the search_tweet function with the words OR or AND.

to prouve it juste try this two lines

tweet=stream_tweets("covid",token = token) many result

tweet2=stream_tweets("covid OR vaccin",token = token) #no result ,

Can you please help and if is not possible, do you know an other solution ? thank you very much


Solution

  • rtweet is currently using version 1 of the Twitter API. Documentation for the stream functionality can be found here. Specifically, this bit is important:

    A comma-separated list of phrases which will be used to determine what Tweets will be delivered on the stream. A phrase may be one or more terms separated by spaces, and a phrase will match if all of the terms in the phrase are present in the Tweet, regardless of order and ignoring case. By this model, you can think of commas as logical ORs, while spaces are equivalent to logical ANDs (e.g. ‘the twitter’ is the AND twitter, and ‘the,twitter’ is the OR twitter).

    In other words, this will get you tweets with "covid" OR "vaccin":

     tweets <- rtweet::stream_tweets(q = "covid, vaccin")
    

    This will get you tweets with "covid" AND "vaccin":

    tweets <- rtweet::stream_tweets(q = "covid vaccin")