[英]R Shiny reactive time to trigger at specific time and not specific interval
Hopefully a simple question. 希望是一个简单的问题。 I have a line like this in a shiny app that works fine:
我在闪亮的应用程序中有这样的代码,可以正常工作:
autoInvalidate <- reactiveTimer(120000)
Is there anyway to set an event to execute say every 5 minutes on the minute and not just set intervals apart? 无论如何,是否有一个事件设置为每分钟每5分钟执行一次,而不仅仅是设置间隔? So for example if the app is launched at 6:03pm it will execute the reactive element at 6:05pm then 6:10pm then 6:15pm etc.
因此,例如,如果应用程序在下午6:03启动,它将在6:05 pm然后6:10 pm然后6:15 pm执行反应式元素,依此类推。
It might depend on the reactive element you are trying to update, but you could conceivably do this with reactive polling and floor_date
from the lubridate
package. 它可能取决于您要更新的反应性元素,但是可以想象,可以使用
lubridate
软件包中的反应性轮询和floor_date
来执行此lubridate
。
So, you'd have some reactive element that relies on data supplied by a reactivePoll
function, and this data updates at every 5 minute interval, like so: 因此,您将有一些反应性元素依赖于由
reactivePoll
函数提供的数据,并且该数据每隔5分钟更新一次,如下所示:
data <- reactivePoll(intervalMillis = 60000, session,
checkFunc = function() {
#check the time, rounded down to the previous 5 minute interval
lubridate::floor_date(Sys.time(), "5 mins")
},
valueFunc = function() {
#if checkFunc value has changed since the last check, return some updated value or updated dataset
get_value()
}
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.