[R] batch file output
I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore C:\users\me\file.R C:\users\me\file.out 21 Is there any way to get only the output of R in file.out, without getting all the code from file.R too? Any help greatly appreciated, Mikkel __ 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] batch file output
On Dec 28, 2010, at 8:09 AM, Mikkel Grum wrote: I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore C:\users\me \file.R C:\users\me\file.out 21 Is there any way to get only the output of R in file.out, without getting all the code from file.R too? Put a sink(file=C:\users\me\file2.out) in the file.R would be one way but your general strategy looks a bit strange. One does not generally use the interactive version of R for batch execution. See: http://stat.ethz.ch/R-manual/R-patched/library/utils/html/BATCH.html -- David Winsemius, MD West Hartford, CT __ 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] batch file output
On Dec 28, 2010, at 8:27 AM, David Winsemius wrote: On Dec 28, 2010, at 8:09 AM, Mikkel Grum wrote: I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore C:\users\me \file.R C:\users\me\file.out 21 Is there any way to get only the output of R in file.out, without getting all the code from file.R too? Put a sink(file=C:\users\me\file2.out) Would probably work better to use forward slashes. in the file.R would be one way but your general strategy looks a bit strange. One does not generally use the interactive version of R for batch execution. See: http://stat.ethz.ch/R-manual/R-patched/library/utils/html/BATCH.html -- David Winsemius, MD West Hartford, CT __ 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] batch file output
On Tue, Dec 28, 2010 at 8:09 AM, Mikkel Grum mi2kelg...@yahoo.com wrote: I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore C:\users\me\file.R C:\users\me\file.out 21 Is there any way to get only the output of R in file.out, without getting all the code from file.R too? Any help greatly appreciated, Mikkel Try Rscript.exe in your R distribution. Also in the batchfiles distribution, http://batchfiles.googlecode.com, there is a file #Rscript.bat, that can be used to turn an R script into a Windows batch file. #Rscript without arguments gives instructions. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] batch file output
Thanks. The way I run it, I can determine what version of R to run with which script. Don't know how to do that with R CMD BATCH. Placing options(echo = FALSE) in the infile solves my problem. I got that from the page you linked to. Mikkel --- On Tue, 12/28/10, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] batch file output To: David Winsemius dwinsem...@comcast.net Cc: Mikkel Grum mi2kelg...@yahoo.com, r-help@r-project.org Date: Tuesday, December 28, 2010, 8:30 AM On Dec 28, 2010, at 8:27 AM, David Winsemius wrote: On Dec 28, 2010, at 8:09 AM, Mikkel Grum wrote: I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore C:\users\me\file.R C:\users\me\file.out 21 Is there any way to get only the output of R in file.out, without getting all the code from file.R too? Put a sink(file=C:\users\me\file2.out) Would probably work better to use forward slashes. in the file.R would be one way but your general strategy looks a bit strange. One does not generally use the interactive version of R for batch execution. See: http://stat.ethz.ch/R-manual/R-patched/library/utils/html/BATCH.html -- David Winsemius, MD West Hartford, CT __ 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] batch file output
On Dec 28, 2010, at 10:38 AM, Mikkel Grum wrote: Thanks. The way I run it, I can determine what version of R to run with which script. Don't know how to do that with R CMD BATCH. Seems as though something like this (using absolute path to the instance of R.exe) should work: C:\R\R-2.12.1\bin\R CMD BATCH [options] infile [outfile] At least if I remember my command line Windows conventions ... it's been a few years. -- David. Placing options(echo = FALSE) in the infile solves my problem. I got that from the page you linked to. Mikkel --- On Tue, 12/28/10, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] batch file output To: David Winsemius dwinsem...@comcast.net Cc: Mikkel Grum mi2kelg...@yahoo.com, r-help@r-project.org Date: Tuesday, December 28, 2010, 8:30 AM On Dec 28, 2010, at 8:27 AM, David Winsemius wrote: On Dec 28, 2010, at 8:09 AM, Mikkel Grum wrote: I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore C:\users\me\file.R C:\users\me\file.out 21 Is there any way to get only the output of R in file.out, without getting all the code from file.R too? Put a sink(file=C:\users\me\file2.out) Would probably work better to use forward slashes. in the file.R would be one way but your general strategy looks a bit strange. One does not generally use the interactive version of R for batch execution. See: http://stat.ethz.ch/R-manual/R-patched/library/utils/html/BATCH.html -- David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT __ 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] batch file output
On Tue, Dec 28, 2010 at 5:09 AM, Mikkel Grum mi2kelg...@yahoo.com wrote: I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore C:\users\me\file.R C:\users\me\file.out 21 I'm a bit surprised this worked for you...did you customize your build so that Rterm.exe is in \bin\ rather than a subfolder for its specific architecture? Is there any way to get only the output of R in file.out, without getting all the code from file.R too? I did not see anyone else mention this, so I wanted to add that with R CMD BATCH you can add the --slave argument to avoid needing to add options(echo = FALSE) to all your scripts. The --no-timing option stops proc.time() from running at the end. For example from the command prompt I can run 'sample.R' using 32 bit R: C:\R\R-2.12.1\bin\i386\R CMD BATCH --slave --no-timing sample.R sampleout.txt HTH, Josh Any help greatly appreciated, Mikkel __ 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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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.