[R] speed in batch mode versus interactive mode

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Feb 15 01:45:03 CET 2004


karl cottenie <cottenie at nceas.ucsb.edu> writes:

> Hello R-users,
> 
> is there a speed gain in submitting R code in batch mode as opposed to
> the normal interactive. I searched the R website and the archives, and
> only found a reference R-data.html that "to read in very large objects
> it may be preferable to use the dumpfile as a batch script rather than
> source". Is this true for any R code on both Windows and Linux systems,
> and how much speed improvement can be gained (5 % or maybe 20 %)?

Well, you could try it and see... The statement in R-data.html would
seem to only marginally related to your question since it is about
restoring objects created by dump() and I'm not even sure it is true
in that case. 

The source() command will parse the whole input before executing
anything, which may carry a space penalty on (very) long scripts. On
the other hand complicated expressions on standard input may get
reparsed from the start several times until R is satisfied that the
expression is complete.

Another issue is that interactive R (in the Windows GUI at least) may
have trouble getting rid of its output fast enough; this is why we
have the option of buffering the console output, but batch mode does
not have this problem.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list