我是R的新手,当然也是RShiny的新手。
我写了一个包,将事件记录到日志文件中。Rstudio能够查看实时日志,但文件大小为5MB。因此,现在我正在考虑编写一个Rshiny应用程序,它可以在日志被写入文件时查看它们。
哪些函数可以帮助我更新查看器?
谢谢!
发布于 2020-10-05 17:29:00
您可以在导入数据时在reactive
中调用invalidateLater
。每次invalidateLater
触发时都会刷新数据(在我的例子中是每秒刷新一次)。
这里有一个非常愚蠢的例子(我的.csv没有更新,它只是打印正在刷新到控制台的数据):
library(shiny)
ui <- fluidPage(
tableOutput("data")
)
server <- function(input, output, session) {
# mtcars.csv will be read every second
mtcars_df <- reactive({
invalidateLater(1000, session)
read.csv("mtcars.csv")
})
# mtcars_df is a reactive, hence will force the table to re-render
output$data <- renderTable({
print(paste("Table refreshed at", Sys.time(), collapse = " "))
mtcars_df()
})
}
shinyApp(ui, server)
https://stackoverflow.com/questions/64205237
复制相似问题