我正在使用R包rtweet直播实时鸣叫。
一切正常,但是我想要的是将信息自动存储在Google Big Query中并在Data Studio上显示,并且该信息应每X次更新一次(例如5分钟)。
我该怎么办?问题是在进行广播时,R会话很忙,所以我无能为力。
我还会考虑停止流式传输一秒钟以存储信息并在...之后恢复它。
这是我的代码:
library(rtweet)
library(bigrquery)
token <- create_token(
app = "app name",
consumer_key = "consumer_key ",
consumer_secret = "consumer_secret ",
acess_token = "acess_token",
access_secret = "access_secret")
palabras <- ""
streamtime <- 2 * 60
rt <- stream_tweets(q = palabras, timeout = streamtime)
#This is what I want to do each X time to store the information in Big Query:
insert_upload_job("project id", "dataset name", "table name", df, write_disposition = "WRITE_APPEND")
感谢所有人
答案 0 :(得分:0)
我对R不太了解,但是我有一个类似的案例,尽管stream_tweets()
正在运行,但是等待超时,这没什么可做的。
我不确定是否可行,但是stream_tweets()
创建了一个JSON对象,该对象在函数运行时被填充。在将新项目添加到JSON中并将其存储到Big Query中时,将无法运行其他R脚本吗?例如,将您的代码一分为二并并行运行?
希望我的回答给你一些想法。