Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Shiny app shows old data

Tags:

shiny

I have shiny app, which is displaying old data (4 days delay!) though on the server data are refreshed (current day).

What is strange the old dataset does not exist on the server - seems only existing in Shiny cache.

On the server I have 1 dataset done by cron on May 18, and 1 dataset done by manual refresh 24 May. However Data in the app are from May 20! In the report I display date of dataset creation time - that's why I know the data does not exist any more.

Is it posible to reset Shiny cache somehow?

I also have simmilar problems for some other reports. What is strange for some reports it happends, for some not ...

like image 299
logician Avatar asked May 24 '16 08:05

logician


People also ask

Why is my Shiny app not working?

Your application may be dependent on packages that are installed and loaded in your environment, but aren't installed for the correct user on the Shiny Server. Make sure that all necessary packages are installed for the same user set under run_as in your Shiny Server configuration file.


1 Answers

I found that cache of R Shiny server is updated when the date of creation for the file "app.R" is changed.

So, here is the trick I used:

server <- function(input, output, session) {

   # Trick file date creation update
   onStop(function() {

     # File name
     p <- paste0(getwd(), "/app.R")

     # Update file 'date creation'
     Sys.setFileTime(p, now())

  }) # onStop

 ...


} # server

The idea is to update the date of "app.R" creation after each session.

like image 67
Andrii Avatar answered Sep 19 '22 08:09

Andrii