I have a shiny app that outputs data from a data.frame imported with rdrop2
from my personal Dropbox.
The .csv
file in my Dropbox from which the data.frame is built updates itself regularly. Therefore, I would like my Shiny App to regularly reload the .csv
file and to update the data outputs if the values have changed.
I've already read these two posts: How to trigger a data refresh in shiny? and Update a data frame in shiny server.R without restarting the App, but I really can't make it happen entirely.
For now, I have this code, which seems to do the job, the only thing is that it updates the outputed data all the time, not only if it has changed:
shinyServer(function(input,output,session){
sourceData <- reactive({
invalidateLater(1000,session)
loadData()
})
output$text1 <- reactive({
df<-sourceData()
df$SEX[2]
})
})
The loadData()
function is :
loadData <- function(){
filesInfo <- drop_dir("J-Stats")
filePaths <- filesInfo$path[2]
data <- lapply(filePaths, drop_read_csv, stringsAsFactors = FALSE)
df <- do.call(rbind, data)
df
}
I've also made attempts with reactiveValues
, without success.
Basically, I would like the users of this app to see values that aren't flicking all the time, but just update when the app notices a change while it reloads the data "in the background".
Thanks a lot