tags:

views:

271

answers:

2
+12  Q: 

Automating R Script

I have written an R script that pulls some data from a database, performs several operations on it and post the output to a new database.

I would like this script to run every day at a specific time but I can not find any way to do this effectively.

Can anyone recommend a resource I could look at to solve this issue? I am running this script on a Windows machine.

+1  A: 

You can use Windows Task Scheduler.

Mark Byers
+13  A: 

Supposing your R script is mytest.r, located in D:\mydocuments\, you can create a batch file including the following command:

C:\R\R-2.10.1\bin\Rcmd.exe BATCH D:\mydocuments\mytest.r

Then add it, as a new task, to windows task scheduler, setting there the triggering conditions.

You could also omit the batch file. Set C:\R\R-2.10.1\bin\Rcmd.exe in the program/script textbox in task scheduler, and give as Arguments the rest of the initial command: BATCH D:\mydocuments\mytest.r

gd047
Using `Rscript` is preferable to `R BATCH`. Systems that can differentiate between lower- and upper-case get `r` as well.
Dirk Eddelbuettel
Thanks, I hadn't used it. As I saw, arguments can also be passed to the script and be accessed using commandArgs
gd047