[R] Capturing buffered output from Rterm

Keith Jewell k.jewell at campden.co.uk
Thu Jun 10 12:31:25 CEST 2010


In MS Windows I
  a) invoke Rterm from a batch file (test.bat)
  b) to execute commands from a script (m:\test.rsc)
  c) capturing output in a log file (m:\test.log)
BUT if the script results in an error the error message is NOT written to 
the log file, leaving me problems when the error is from a complicated 
function.

Simplified example:.

test.bat ------------------------
REM ensure 'R' is in path
path \\Server02\stats\R\R-Current\bin\;%PATH%
Rterm  --no-init-file --no-restore-data --no-save --silent < m:\test.rsc > 
m:\test.log
---------------------

m:\test.rsc -----------------
print("this is a test")
#generate an error
nls()
------------------

The error message:
  "Error in .Internal(inherits(x, what, which)) : 'x' is missing"
is is NOT written to the log file, which just ends

m:\test.log --------------------------
  <snip>
> print("this is a test")
[1] "this is a test"
> #generate an error
> nls()
---------------------

I surmise this is due to output buffering (?). In an S-Plus version I turned 
off buffering with
  guiSetOption(option.name="BufferOutputWindows", value.string="F")
but I don't think this is available in R (?).

Has anyone any suggestions?

Thanks in advance,

Keith Jewell
--please do not edit the information below--

R Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status =
 major = 2
 minor = 11.0
 year = 2010
 month = 04
 day = 22
 svn rev = 51801
 language = R
 version.string = R version 2.11.0 (2010-04-22)

Windows Server 2003 x64 (build 3790) Service Pack 2

Locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United 
Kingdom.1252;LC_MONETARY=English_United 
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

Search Path:
 .GlobalEnv, package:datasets, CBRIForecast, package:RODBC, package:tree, 
package:locfit, package:lattice, package:akima, package:nlme, package:MASS, 
package:grDevices, package:geometry, KJRutils, package:xlsReadWrite, 
package:svSocket, package:TinnR, package:R2HTML, package:Hmisc, 
package:survival, package:splines, package:graphics, package:stats, 
CBRIutils, package:utils, package:tcltk, package:tools, package:methods, 
TempEnv, Autoloads, package:base



More information about the R-help mailing list