Re: [R] Automating R script with Windows 7
I would try first without the task scheduler: Make a .bat file and run this from the command line. This way you can see what is going on without the flashing window that is opened and closed immeadiately. maviney wrote I tried to task schedule, using the following code C:\Program Files\R\R-2.12.1\bin\i386\Rscript.exe but the Rscript just flashes at me Thanks for ur assistance, its back to researching my problem -- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4635380.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Automating R script with Windows 7
Sounds like operating system troubles, not R troubles. If you want help with invoking R, please take a deep breath, read the FAQs and the posting guide, and tell us exactly what you did at the command line if you still think R is the problem. Note that any problems you may be having with the access permissions that your interactive or automatically-triggered environment is restricted by are almost impossible for us to remotely troubleshoot, and are not on-topic for this mailing list. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. maviney mvine...@hotmail.com wrote: hi i have tried all day in getting this to work, but i have fail I cant even schedule it to open up rscript, even by manually i cant open rscript Pls help -- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4635237.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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. __ R-help@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.
Re: [R] Automating R script with Windows 7
On Mon, Mar 5, 2012 at 2:47 PM, vincent.deluard vincentdelua...@gmail.com wrote: Hi Jim, Please disregard my earlier post -- I have done some research and realized the space between after program was the the issue. I can now open RScript.exe from the command prompt using the abbreviated form: C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe From your earlier post, I understand the structure to type in the command prompt should be: 'Path to RScript.exe' SPACE 'Path to the .R file I want to execute' Which should translate as the following on my machine: C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe \C:\Users\Vincent\Documents\temp\test.r Yet I get the following error message: 'Fatal Error: cannot open file \C:\Users\Vincent\Documents\temp\test.r' I don't think you want the first backslash in the test.r path, i.e., it should be C:\Users\Vincent\Documents\temp\test.r instead of \C:\Users\Vincent\Documents\temp\test.r Best, Ista What am I doing wrong? Thanks for your help! -- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4447406.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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. __ R-help@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.
Re: [R] Automating R script with Windows 7
In R you should slashes instead of backslashes: C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe C:/Users/Vincent/Documents/temp/test.r Bart -- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4635260.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Automating R script with Windows 7
Thank you for your help So i have tried many ways on different computers, but i believe i have an operating system, as I open RScript up in my local directory it just flashes at me and them disappears I tried to task schedule, using the following code C:\Program Files\R\R-2.12.1\bin\i386\Rscript.exe but the Rscript just flashes at me Thanks for ur assistance, its back to researching my problem -- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4635275.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Automating R script with Windows 7
I did not suggest that you don't HAVE an operating system... simply that you don't know how to use yours. However you accomplish starting programs automatically, you WILL need to specify both the R interpreter (which you do seem to be accomplishing) and the name of the script you wish to run (which you don't appear to be doing). Appropriate use of quoting may be necessary if you have spaces in your paths. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. maviney mvine...@hotmail.com wrote: Thank you for your help So i have tried many ways on different computers, but i believe i have an operating system, as I open RScript up in my local directory it just flashes at me and them disappears I tried to task schedule, using the following code C:\Program Files\R\R-2.12.1\bin\i386\Rscript.exe but the Rscript just flashes at me Thanks for ur assistance, its back to researching my problem -- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4635275.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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. __ R-help@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.
Re: [R] Automating R script with Windows 7
hi i have tried all day in getting this to work, but i have fail I cant even schedule it to open up rscript, even by manually i cant open rscript Pls help -- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4635237.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Automating R script with Windows 7
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 vincentdelua...@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@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. __ R-help@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.
Re: [R] Automating R script with Windows 7
vincent.deluard vincentdelua...@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 __ R-help@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.
Re: [R] Automating R script with Windows 7
I created a txt file with R commands in it and then a batch file to process the txt file. The batch file could be scheduled. The batch file is: REM on Microsoft Windows (adjust the path to R.exe as needed) C:\Program Files\R\R-2.13.2\bin\x64\R.exe CMD BATCH C:\Users\Frank\Documents\R\Scripts\Multi_Graph.txt C:\Users\Frank\Documents\R\Scripts\Multi_Graph.out PAUSE The text file is: x - seq(-4, 4, length=100) hx - dnorm(x) degf - c(1, 3, 8, 30) colors - c(red, blue, darkgreen, gold, black) labels - c(df=1, df=3, df=8, df=30, normal) pdf(C:\\Users\\Frank\\Documents\\R\\Scripts\\Norm_Graph.pdf) plot(x, hx, type=l, lty=2, xlab=x value, ylab=Density, main=Comparison of t Distributions) for (i in 1:4){ lines(x, dt(x,degf[i]), lwd=2, col=colors[i]) } legend(topright, inset=.05, title=Distributions, labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors) This produces a nice plot. Frank Date: Mon, 5 Mar 2012 08:55:44 -0800 From: vincentdelua...@gmail.com To: r-help@r-project.org Subject: [R] Automating R script with Windows 7Hi 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@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. __ R-help@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.
Re: [R] Automating R script with Windows 7
Hey Jim, Thanks for the help. It took me a little bit of research but I got your solution to work. For everybody who has the same problem (1) remember to use the abbreviated names (no space) in folder paths: ex: 'C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe' (2) put the folder with the R script to run in the same location (in my case: C:\) C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe \temp\dailyroutine.r Using the task scheduler in Windows 7.0 is straightforward. Vincent Deluard, CFA -- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4447669.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Automating R script with Windows 7
You are looking to run R in batch mode see How to run R in batch mode [1] and the Quick-R on Batch Processing [2] [1] http://turing.une.edu.au/~stat356/Rbatch.html [2] http://www.statmethods.net/interface/batch.html On Mon, Mar 5, 2012 at 8:55 AM, vincent.deluard vincentdelua...@gmail.comwrote: 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@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Automating R script with Windows 7
Hi Jim, Please disregard my earlier post -- I have done some research and realized the space between after program was the the issue. I can now open RScript.exe from the command prompt using the abbreviated form: C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe From your earlier post, I understand the structure to type in the command prompt should be: 'Path to RScript.exe' SPACE 'Path to the .R file I want to execute' Which should translate as the following on my machine: C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe \C:\Users\Vincent\Documents\temp\test.r Yet I get the following error message: 'Fatal Error: cannot open file \C:\Users\Vincent\Documents\temp\test.r' What am I doing wrong? Thanks for your help! -- View this message in context: http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4447406.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.