R 如何在每个特定时间段重新读取数据

R 如何在每个特定时间段重新读取数据,r,shiny,reactive-programming,R,Shiny,Reactive Programming,我正在用Shiny创建一个程序,我有以下问题:我的数据文件每分钟都会自动更改,我想显示数据文件中的绘图等信息。如何使应用程序每分钟自动重新读取数据帧?我的问题是,我必须使用自己创建的函数来读取数据,因此我不会使用诸如read.table或read.csv之类的函数来读取数据 我将尝试提供我拥有的代码示例: ui <- dashboardPage( dashboardBody( selectInput("estprediction" , label = "Est" , choices = c

我正在用Shiny创建一个程序,我有以下问题:我的数据文件每分钟都会自动更改,我想显示数据文件中的绘图等信息。如何使应用程序每分钟自动重新读取数据帧?我的问题是,我必须使用自己创建的函数来读取数据,因此我不会使用诸如
read.table
read.csv
之类的函数来读取数据

我将尝试提供我拥有的代码示例:

ui <- dashboardPage(
dashboardBody(
selectInput("estprediction" , label = "Est" , choices = c("A1" , "A2" , "A3"  , "A4" , "A5" , "A6" , "A7"),selectize = TRUE)),
plotOutput(outputId = "predictionplot"))
)
server <- function(input, output) {
data1 <- readweirddata("A1")
data2 <- readweirddata("A2")
...
data7 <- readweirddata("A7")
  fecha_min <- as.POSIXct(mutate(data1,Date = paste(Year, Month, Day, Hour, Min, sep = "-"))$Date,format = "%Y-%m-%d-%H-%M") 

estpred <- reactiveValues(data=data1)
observeEvent(input$estprediction, {
    if (input$estprediction== "A1"){estpred$data = data1}
    if (input$estprediction== "A2"){estpred$data = data2}
    if (input$estprediction== "A3"){estpred$data = data3}
    if (input$estprediction== "A4"){estpred$data = data4}
    if (input$estprediction== "A5"){estpred$data = data5}
    if (input$estprediction== "A6"){estpred$data = data6}
    if (input$estprediction== "A7"){estpred$data = data7}
  })

 output$predictionplot <- renderPlot({
    df <- data.frame(fecha_min,estpred$data[c(1,2,4)])
    ggplot(df, aes(fecha_min)) + 
    geom_line(size=1,aes(y = estpred$data[1], colour = paste("Var1", "min(μg/m3)")))} +
geom_line(size=1,aes(y = estpred$data[2], colour = paste("Var1", "min(μg/m3)")))} +
geom_line(size=1,aes(y = estpred$data[4], colour = paste("Var1", "min(μg/m3)")))} 

  })

}




ui参见
?reactiveFileReader
@Stéphanelant,我已经这样做了,但我不知道如何在我的示例中使用它。我的意思是:我应该使用
reactiveFileReader(1000,NULL,readweirddata(“A1”),NULL)
?或者我该怎么做?我遇到这个问题是因为我必须使用这个函数
readweirddata参见
?reactiveFileReader
@Stéphanelant,我已经使用过了,但我不知道如何在我的示例中使用它。我的意思是:我应该使用
reactiveFileReader(1000,NULL,readweirddata(“A1”),NULL)
?或者我该怎么做?我遇到了这个问题,因为我必须使用这个函数
readweirddata