我正在从两个网址读取实时数据到Shiny,并显示最近更新的8条记录。然而,这些数据并不是最新的,
即显示前几天的记录,与来自url的实时记录不一致,
除非我再次粘贴并在浏览器中打开/刷新url。我想知道这是不是缓存的问题,我应该如何修改我的代码?
library(shiny)
shinyApp(
ui <- fluidPage(
column(3,
selectInput("station", "Select station",
c("a", "b")),
tableOutput("table")
)
),
server <- function(input, output) {
df <- eventReactive(input$station, {
if (input$station == "a") {
tail(read.csv("https://datagarrison.com/users/300234062103550/300234062107550/temp/Dawson_Creek__008.txt",
sep = "\t", skip = 2)[, c("Date_Time", "Rain_2440445_mm")], 8)
} else {
tail(read.csv("http://datagarrison.com/users/300234062103550/300234064336030/temp/10839071_004.txt",
sep = "\t", skip = 2)[, c("Date_Time", "Rain_2007476_mm")], 8)
}})
output$table <- renderTable(
df()
)
})
更新:结果是服务器本身遇到了更新问题,而不是代码。然而,答案显示了一种有用的方法。
https://stackoverflow.com/questions/50747052
复制相似问题