Schedule automatic updates in R

4

I have an algorithm in the R designed that retrieved data from a database, does some statistical calculations and produces a dashboard with kpis and graphs generated from those calculations. But, every time I want to update the information, I have to execute the function so that the calculations are redone. Is there any way I can schedule an automatic update of these calculations in R once I open the code and while I leave it open?

    
asked by anonymous 17.07.2017 / 01:58

1 answer

5

Yes, there is. On a past job of mine, we built a shiny dash that was basically a while (true) and Sys.sleep(5) that kept updating the dashboard data.

It would certainly be necessary to refactor the code for this new structure.

However, I do not know if I would do it today. I would probably do the extraction and update of a local database with a dedicated script only (probably in python , but could be in R same) and I would run it periodically with cron job if your OS for * nix or with Task Scheduler in Windows.

If data processing is very complex, with multiple dependencies and decisions in the process, it would make an application with Make (which has a package to facilitate in the R language) or would have a local server / process with Airflow or% with% would only take account of the extraction and processing of the data, and the Dash application would only connect with the data source, updating at each X time or with an update button, leaving it to the user. >     

18.07.2017 / 16:51