Re: [R] Capturing buffered output from Rterm

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu, 10 Jun 2010 13:42:11 +0100 (BST)

On Thu, 10 Jun 2010, Keith Jewell wrote:

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

Sure, warning and errors are written to stderr, which you did not redirect. This is covered in rw-FAQ Q2.12. Using R CMD BATCH would have done this for you ....

This is not to do with 'buffered output': in any case R uses minimal buffering so stdout and stderr can be mixed nicely on a single log file.

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

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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 - 12:45:45 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 - 13: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