I usually just run my R programs at the R command prompt but for my latest one I want to save any output that gets written to the screen so I am trying to use R CMD BATCH and send the output to an output file. I realize I could use sink at the prompt but I'd rather try to do it this way because I know that I used to do this in S+. So, I wrote a simple one line program called test.R which is below. print("test of batch\n") Then I did R CMD BATCH temp.R temp.out temp.out which is shown below then ends up containing all my loading up messages and a proc.time statement at the very bottom but not the print statement itself ? Does someone know what I'm doing wrong. I've looked around but I can't find anything that answers my question. My sessionInfo() is at ther very bottom of this email. Thanks. #================================================================================== R version 2.7.2 (2008-08-25) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [1] "LOADING MASS LIBRARY" Loading required package: graphics Loading required package: stats Loading required package: utils [Previously saved workspace restored] Welcome to R! delete workspace? (y/n): print("test of batch\n") [1] "LOADING LPSOLVE LIBRARY \n" [1] "LOADING RESHAPE LIBRARY \n" [1] "LOADING FILEHASH LIBRARY \n" filehash: Simple key-value database (2.0 2008-08-03) [1] "LOADING USINGR LIBRARY \n" [1] "LOADING CAR LIBRARY \n" [1] "LOADING EFFECTS LIBRARY \n" Loading required package: lattice Loading required package: grid Attaching package: 'effects' The following object(s) are masked from package:car : Cowles, Prestige [1] "LOADING NNET LIBRARY \n" [1] "LOADING LATTICE LIBRARY \n" [1] "LOADING ML FUTURES TOOLS LIBRARY" [1] "LOADING ML MISC TOOLS LIBRARY" [1] "LOADING ML TEST TOOLS LIBRARY" [1] "LOADING ML STOCK TOOLS LIBRARY" [1] "LOADING ML DECILE TOOLS LIBRARY" [1] "LOADING ML MULTINOM TOOLS LIBRARY" The following object(s) are masked from package:utils : memory.size> >Goodbye!> proc.time()user system elapsed 3.061 0.087 3.252 #=================================================================================== sessionInfo() R version 2.7.2 (2008-08-25) i686-redhat-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] datasets grid utils stats graphics grDevices methods base other attached packages: [1] nnet_7.2-44 effects_1.0-12 lattice_0.17-14 car_1.2-8 UsingR_0.1-8 filehash_2.0 reshape_0.8.0 lpSolve_5.6.4 MASS_7.2-44
On 30/10/2008, at 10:46 AM, markleeds at verizon.net wrote:> I usually just run my R programs at the R command prompt but for my > latest one I want to save any output that gets written to the > screen so > I am > trying to use R CMD BATCH and send the output to an output file. I > realize I could use sink at the prompt but I'd rather try to do it > this > way > because I know that I used to do this in S+. > > So, I wrote a simple one line program called test.R which is below. > > print("test of batch\n")Uh, you don't ack-chewally want that ``\n'' in there with a print() statement. (You'd want it with a cat() statement.)> > Then I did > > R CMD BATCH temp.R temp.outDid you mean ``test.R'' here, rather than ``temp.R''? If not, what's in ``temp.R''?> > temp.out which is shown below then ends up containing all my > loading up > messages and a proc.time statement at the very bottom but not the > print statement itself ? Does someone know what I'm doing wrong. I've > looked around but I can't find anything that answers my question. My > sessionInfo() is at ther very bottom of this email. Thanks.<snip> Well, it works for *me*! I made a file temp.R containing the line ``print("test of batch") and then did: R CMD BATCH temp.R temp.out The resulting file temp.out contained the ``test of batch'' line as expected/required. No problema. Clearly the R gods don't like you. :-) cheers, Rolf ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
thanks Rolf. Yes, I meant temp.R. I was going to use test.R but then I realized that I already had a program named that. I think the R gods are really hating me !!!!!!! it's a very odd thing. I'll grep the file because maybe the output is in there somewhere and i'm missing it ? On Wed, Oct 29, 2008 at 5:01 PM, Rolf Turner wrote:> On 30/10/2008, at 10:46 AM, markleeds at verizon.net wrote: > >> I usually just run my R programs at the R command prompt but for my >> latest one I want to save any output that gets written to the screen >> so >> I am >> trying to use R CMD BATCH and send the output to an output file. I >> realize I could use sink at the prompt but I'd rather try to do it >> this >> way >> because I know that I used to do this in S+. >> >> So, I wrote a simple one line program called test.R which is below. >> >> print("test of batch\n") > > Uh, you don't ack-chewally want that ``\n'' in there with > a print() statement. (You'd want it with a cat() statement.) >> >> Then I did >> >> R CMD BATCH temp.R temp.out > > Did you mean ``test.R'' here, rather than ``temp.R''? > If not, what's in ``temp.R''? >> >> temp.out which is shown below then ends up containing all my loading >> up >> messages and a proc.time statement at the very bottom but not the >> print statement itself ? Does someone know what I'm doing wrong. >> I've >> looked around but I can't find anything that answers my question. My >> sessionInfo() is at ther very bottom of this email. Thanks. > > <snip> > > Well, it works for *me*! > > I made a file temp.R containing the line ``print("test of batch") > and then did: > > R CMD BATCH temp.R temp.out > > The resulting file temp.out contained the ``test of batch'' line > as expected/required. > > No problema. > > Clearly the R gods don't like you. :-) > > cheers, > > Rolf > > ###################################################################### > Attention:This e-mail message is privileged and confidential. If you > are not theintended recipient please delete the message and notify the > sender.Any views or opinions presented are solely those of the author. > > This e-mail has been scanned and cleared by > MailMarshalwww.marshalsoftware.com > ######################################################################