Is the countdown timer in R brilliant?

I want to display the current time in my brilliant app. Therefore, I can use Sys.time()

 function(input, output, session) { output$currentTime <- renderText({ invalidateLater(1000, session) paste("The current time is", Sys.time()) }) } 

I am wondering if it is also possible to encode a countdown timer depending on the current time, for example. upcoming event?

+5
source share
1 answer

The following code should do (suppose the event has passed only 4 minutes):

 EventTime <- Sys.time() + 4*60 output$eventTimeRemaining <- renderText({ invalidateLater(1000, session) paste("The time remaining for the Event:", round(difftime(EventTime, Sys.time(), units='secs')), 'secs') }) 

with the following output:

 The time remaining for the Event: 226 secs 
+5
source

All Articles