[R] Automating R script with Windows 7
Mikhail Titov
mlt at gmx.us
Mon Mar 5 19:30:28 CET 2012
"vincent.deluard" <vincentdeluardr at gmail.com> writes:
> I am trying to automate the daily running of a simple R script from Windows
> 7.
>>From previous posts, I understand that this needs to be done with the task
> scheduler.
That is correct.
> I can schedule my laptop to automatically open R at a certain time, but not
> to execute a script.
For example you can use
schtasks /create /tn "My R task" /sc DAILY /ST 03:00:00 /TR
C:\path_to_your_batch_file.cmd
to start task daily at 3am.
> Secondary question: how do I save a list of R commands so that they get
> executed once the file is open?
I highly recommend to read a manual on Rscript and use it in your batch
file instead of the "source"-ing mentioned below.
> Right now, I save my code in a notepad doc and paste over in R, but there
> has to be another way.
Consider using some IDE. If not Emacs+ESS or Eclipse, then at least Tinn-R.
> I have tried saving my code as .r file using the
> editor and open the file with R later but this does not seem to execute the
> code.
You should "source" your file to "execute" it, i.e.
source("path_to_my.R")
--
Mikhail
More information about the R-help
mailing list