[R] Automating R script with Windows 7

jim holtman jholtman at gmail.com
Mon Mar 5 19:26:37 CET 2012


Just save your R script as a plain text file.  Here is a copy of a
file that I will show you how to execute; it is saved as \temp\test.r

cat('this is my R script executing\n', format(Sys.Date()))

Here is the command that I execute at the 'CMD' prompt and that you
would have scheduled by Windows:

C:\R-2.14.2\bin\i386\Rscript.exe \temp\test.r

This has the full path name (on my machine) to the 'Rscript.exe'
program included in R for executing scripts

Here is the output from the execution on the command prompt screen:

>C:\R-2.14.2\bin\i386\Rscript.exe \temp\test.r
this is my R script executing
 2012-03-05

So it is easy to setup.  Let me know if you have any problems.

On Mon, Mar 5, 2012 at 11:55 AM, vincent.deluard
<vincentdeluardr at gmail.com> wrote:
>
> Hi R-users,
>
> 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.
> I can schedule my laptop to automatically open R at a certain time, but not
> to execute a script.
>
> Secondary question: how do I save a list of R commands so that they get
> executed once the file is open?
> Right now, I save my code in a notepad doc and paste over in R, but there
> has to be another way. 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.
>
> I very much appreciate the help.
>
> Vincent Deluard, CFA
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4446693.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.



More information about the R-help mailing list