Best way to automatically update data connection on schedule or on changes?

I have a working Shiny app that is contained in a flexdashboard. I have not been able to figure out the best way to automatically refresh the data connection every 15 minutes.

I'm using a special function to read the csv file (skipping 3 rows), so I'm not sure how to proceed.

title: "Dashboard"
orientation: rows
veritcal_layout: scroll
source_code: embed
runtime: shiny

Row {data-height=650}

### DataGraph 1

````{r global, include=FALSE}
library(lubridate) = function(file, ..., skip.rows=NULL, tolower=FALSE){
if (!is.null(skip.rows)) {
    tmp = readLines(file)
    tmp = tmp[-(skip.rows)]
    tmpFile = tempfile()
    file = tmpFile
result = read.csv(file, ...)
if (tolower) names(result) = tolower(names(result))

data <-"last8hours.csv", skip.rows = 2:3, tolower = T))
data$x <- as.POSIXct(data$x, format= "%d-%b-%Y %H:%M")
datah <-"last24.csv", skip.rows = 2:3, tolower = T)
datah$x <- as.POSIXct(datah$x, format= "%d-%b-%Y %H:%M")

I would like to either detect file changes or schedule an update on the data and datah connections every 15 minutes. What is the best way to achieve this and how might it look with the function I'm using to read the csv files?

I think you may be interested by this function reactiveFileReader

For more custom source, you have also reactivePoll

or reactiveTimer for invalidation of reactive

You'll find example in

Hope it helps

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.