Re: [R] Writing R Scripts and passing command line arguments
Hi All Thanks for the pointers. reading them I see that what I intend to can certainly be done without much pain. However with my test scripts I am not able to fully understand Rscript. The ?Rscript option doesnt print out a lot to help me get the minute details. Any good example/s or some info on Rscript will help. Thanks, -Abhi On Mon, Sep 7, 2009 at 2:37 PM, cls59 ch...@sharpsteen.net wrote: Abhishek Pratap wrote: 1. What's the best way to pass command line arguments to R scripts ? As Gabor mentioned, the commandArgs function and the getopt package provide some excellent starting points for this. Abhishek Pratap wrote: 2. How to execute R scripts from command line ? When I use R CMD BATCH I see no output on the screen I believe R CMD BATCH dumps all of it's output to a file ending in .Rout. If you want more control over input and output to your script then Rscript is the utility to use. Abhishek Pratap wrote: 3. What does R --slave --vanilla do ? If I recall correctly, --vanilla makes it so that R does not waste time trying to load a previously saved session and also makes it so that R does not try to save history and environment variables when it exits. Vanilla also disables the loading of options from profile files such as ~/.Rprofile. I think --slave makes R shut up about it's self and run more quietly than it normally does. Hope that helps! -Charlie - Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University -- View this message in context: http://www.nabble.com/Writing-R-Scripts-and-passing-command-line-arguments-tp25334067p25334648.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] Writing R Scripts and passing command line arguments
Put this line in a file called test.R: cat(command args are:\n); print(commandArgs()) and then call it like this from the shell or Windows cmd line assuming that Rscript is in your path: Rscript test.R abc def On Wed, Sep 9, 2009 at 2:37 PM, Abhishek Pratap abhishek@gmail.com wrote: Hi All Thanks for the pointers. reading them I see that what I intend to can certainly be done without much pain. However with my test scripts I am not able to fully understand Rscript. The ?Rscript option doesnt print out a lot to help me get the minute details. Any good example/s or some info on Rscript will help. Thanks, -Abhi On Mon, Sep 7, 2009 at 2:37 PM, cls59 ch...@sharpsteen.net wrote: Abhishek Pratap wrote: 1. What's the best way to pass command line arguments to R scripts ? As Gabor mentioned, the commandArgs function and the getopt package provide some excellent starting points for this. Abhishek Pratap wrote: 2. How to execute R scripts from command line ? When I use R CMD BATCH I see no output on the screen I believe R CMD BATCH dumps all of it's output to a file ending in .Rout. If you want more control over input and output to your script then Rscript is the utility to use. Abhishek Pratap wrote: 3. What does R --slave --vanilla do ? If I recall correctly, --vanilla makes it so that R does not waste time trying to load a previously saved session and also makes it so that R does not try to save history and environment variables when it exits. Vanilla also disables the loading of options from profile files such as ~/.Rprofile. I think --slave makes R shut up about it's self and run more quietly than it normally does. Hope that helps! -Charlie - Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University -- View this message in context: http://www.nabble.com/Writing-R-Scripts-and-passing-command-line-arguments-tp25334067p25334648.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. __ 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] Writing R Scripts and passing command line arguments
Hi Guys I am Abhishek, primarily a bioinformatician. I have recently started using a lot of R thanks to some excellent packages available. Lately I have felt the need to batch process few of the R scripts I have been working with and strangely enough I am not able to find a good resource on how to best do this. I did find few old threads on the archives but none convinced me much. So here I am asking the same thing again hoping to get a good solution. 1. What's the best way to pass command line arguments to R scripts ? 2. How to execute R scripts from command line ? When I use R CMD BATCH I see no output on the screen 3. What does R --slave --vanilla do ? Thanks, -Abhi [[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] Writing R Scripts and passing command line arguments
See ?commandArgs, the getopt package and ?Rscript On Mon, Sep 7, 2009 at 1:47 PM, Abhishek Pratapabhishek@gmail.com wrote: Hi Guys I am Abhishek, primarily a bioinformatician. I have recently started using a lot of R thanks to some excellent packages available. Lately I have felt the need to batch process few of the R scripts I have been working with and strangely enough I am not able to find a good resource on how to best do this. I did find few old threads on the archives but none convinced me much. So here I am asking the same thing again hoping to get a good solution. 1. What's the best way to pass command line arguments to R scripts ? 2. How to execute R scripts from command line ? When I use R CMD BATCH I see no output on the screen 3. What does R --slave --vanilla do ? Thanks, -Abhi [[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. __ 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] Writing R Scripts and passing command line arguments
Abhishek Pratap wrote: 1. What's the best way to pass command line arguments to R scripts ? As Gabor mentioned, the commandArgs function and the getopt package provide some excellent starting points for this. Abhishek Pratap wrote: 2. How to execute R scripts from command line ? When I use R CMD BATCH I see no output on the screen I believe R CMD BATCH dumps all of it's output to a file ending in .Rout. If you want more control over input and output to your script then Rscript is the utility to use. Abhishek Pratap wrote: 3. What does R --slave --vanilla do ? If I recall correctly, --vanilla makes it so that R does not waste time trying to load a previously saved session and also makes it so that R does not try to save history and environment variables when it exits. Vanilla also disables the loading of options from profile files such as ~/.Rprofile. I think --slave makes R shut up about it's self and run more quietly than it normally does. Hope that helps! -Charlie - Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University -- View this message in context: http://www.nabble.com/Writing-R-Scripts-and-passing-command-line-arguments-tp25334067p25334648.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.