[R] linux batch question

markleeds at verizon.net markleeds at verizon.net
Wed Oct 29 22:46:46 CET 2008


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



More information about the R-help mailing list