[R] Capturing buffered output from Rterm

From: Keith Jewell <k.jewell_at_campden.co.uk>
Date: Thu, 10 Jun 2010 11:31:25 +0100

In MS Windows I

  1. invoke Rterm from a batch file (test.bat)
  2. to execute commands from a script (m:\test.rsc)
  3. 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

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 --------------------------

> 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

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

R-help_at_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. Received on Thu 10 Jun 2010 - 10:34:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 10 Jun 2010 - 12:50:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive