sách gpt4 ai đã đi

r - R Shiny 的倒数计时器?

In lại 作者:行者123 更新时间:2023-12-04 12:05:22 26 4
mua khóa gpt4 Nike

我想在我 Shiny 的应用程序中显示当前时间。因此,我可以使用 Sys.time()

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

我想知道是否也可以根据当前时间编写倒数计时器,例如即将举行的事件?

1 Câu trả lời

以下代码应该做(假设事件仅提前 4 分钟):

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')
})

具有以下输出:
The time remaining for the Event: 226 secs

关于r - R Shiny 的倒数计时器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39449124/

26 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com