在 streem_tweet 请求 rtweet 中使用布尔值

Use boolean in streem_tweet request rtweet

大家好,我想知道是否以及如何在 rtweet 包的函数 stream_tweet 中使用布尔值。它似乎不像在 search_tweet 函数中使用 OR 或 AND 那样工作。

证明它只是尝试这两行

tweet=stream_tweets("covid",token = token) 许多结果

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

你能帮忙吗?如果不可能,你知道其他解决方案吗?非常感谢

根据 documentation.

stream_tweets 的第一个参数可以采用“带有所需短语和关键字的逗号分隔字符串”

也许 tweet2 = stream_tweets("covid, vaccine", token = token) 就是您要找的。

rtweet 目前正在使用 Twitter API 的版本 1。可以找到流功能的文档 here。具体来说,这一点很重要:

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).

换句话说,这将使您收到带有“covid”或“vaccin”的推文:

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

这将使您收到带有“covid”和“vaccin”的推文:

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