I have an R script that generates a report based on the current contents of a database. This database is constantly in flux with records being added/deleted many times each day. How can I ask my computer to run this every night at 4 am so that I have an up to date report waiting for me in the morning? Or perhaps I want it to re-run once a certain number of new records have been added to the database. How might I go about automating this? I should mention I'm on Windows, but I could easily put this script on my Linux machine if that would simplify the process.
For windows, use the task scheduler to set the task to run for example daily at 4:00 AM
It gives you many other options regarding frequency etc. http://en.wikipedia.org/wiki/Windows_Task_Scheduler
How can I ask my computer to run this every night at 4 am so that I have an up to date report waiting for me in the morning?
You can set up a cronjob on a Linux system. These are run at the set time, if the computer is on. To do so, open a terminal and type:
00 4 * * * r source(/home/FilePath/.../myRscript.R)
Source: Stack Overflow