[R] session logging
marc_schwartz at me.com
Mon Aug 3 23:15:36 CEST 2009
As far as I am aware, the OSX GUI has no logging/transcript feature
per se, short of saving the console output to an external file.
The history file will, as you note, only contain the commands entered
at the R prompt, not the additional output.
One of the solutions would be to use an external editor, which
supports running an R session in such a fashion as to have the console
output directed to a buffer or frame within the editor, which then
itself can just be saved to a file.
There are a fair number of such options, but ESS (Emacs Speaks
Statistics) is common and the one that I have used for a number of
years, on Windows, then Linux and now OSX. ESS allows you to run an R
session within Emacs and thus be able to save the entire R buffer to a
file for future reference. Thus, you can have a complete transcript of
On Aug 3, 2009, at 3:38 PM, Jacob Wegelin wrote:
> Maybe I'm missing something in the history help file. I read it and
> subsequently tried
> but the resulting file does not contain the text that scrolled past
> the console. It contains only a few uninteresting timestamps. Is
> there some more useful application of history() or savehistory()?
> On Mon, Aug 3, 2009 at 4:09 PM, roger koenker <rkoenker at uiuc.edu>
>> have you read
>> url: www.econ.uiuc.edu/~roger Roger Koenker
>> email rkoenker at uiuc.edu Department of Economics
>> vox: 217-333-4558 University of Illinois
>> fax: 217-244-6678 Urbana, IL 61801
>> On Aug 3, 2009, at 3:01 PM, Jacob Wegelin wrote:
>> Consider all the text that one sees on the console during an R
>>> Is there a way, within R, that all this text--i.e., both the
>>> "output" and
>>> the "messages"--can be automatically copied to a single file, in
>>> its being visible on the console?
>>> If I remember to save the console to a file at the end of my R
>>> does it. But
>>> (1) That requires pointing and clicking--can it be automated as a
>>> (2) It would be nice to issue the text command at the start of the R
>>> session, such as "log this entire session in mylog.txt, append",
>>> to ensure
>>> that the session is logged whether I remember to save the console
>>> or not.
>>> As far as I can tell,
>>> will hide the output from me and put it into mylog.txt. But it
>>> still shows
>>> me the error messages.
>>> An attempt to put the output and messages into separate files
>>> returns an
>>> sink("junkout.txt", type="output")
>>>> sink("junkmsg.txt", type="message")
>>> Error in sink("junkmsg.txt", type = "message") :
>>> 'file' must be NULL or an already open connection
>>> and at any rate I'd like both messages in the same file, just like
>>> on the
>>> People who run R at the unix command line apparently use the unix
>>> -script-. But I mean something that will work within R,
>>> A 2003 post to R-help suggests savehistory(), but this does *not*
>>> save the
>>> console; I tried it just now. Another post from the same thread
>>> using emacs. But that is not platform-independent.
>>> The existence of the 2003 thread suggests that this issue comes up
>>> periodically. Was it a deliberate design decision not to make logs
>>> available, in contrast to the way logging works in Stata?
>>> I use the Rgui on a MacBook Pro:
>>> R version 2.8.1 (2008-12-22)
>>> attached base packages:
>>>  stats graphics grDevices utils datasets methods base
>>> other attached packages:
>>>  lme4_0.999375-28 Matrix_0.999375-21 lattice_0.17-17
>>> loaded via a namespace (and not attached):
>>>  boot_1.2-34 grid_2.8.1
>>> Thanks for any insights.
>>> Jacob A. Wegelin
>>> Assistant Professor
>>> Department of Biostatistics
>>> Virginia Commonwealth University
>>> 730 East Broad Street Room 3006
>>> P. O. Box 980032
>>> Richmond VA 23298-0032
>>> E-mail: jwegelin at vcu.edu
>>> URL: http://www.people.vcu.edu/~jwegelin
>>> [[alternative HTML version deleted]]
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide
>>> and provide commented, minimal, self-contained, reproducible code.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help