tags:

views:

211

answers:

6

Is there an easy way to have R record all input and output from your R session to disk while you are working with R interactively? In R.app on Mac OS X I can do a 'File->Save...', but it isn't much help in recovering the commands I had entered when R crashes.

I have tried using sink(...,split=T) but it doesn't seem to do exactly what I am looking for.

+4  A: 

Many of us use ESS / Emacs for this very reason. Saving old sessions with extension '.Rt' even gives you mode-specific commands for re-running parts of your session.

Dirk Eddelbuettel
+2  A: 

Greg Snow wrote recently on the R-help list (a very valuable resource, SO R people!):

"You may also want to look at ?TeachingDemos::txtStart as an alternative to sink, one advantage is that the commands as well as the output can be included. With a little more work you can also include graphical output into a transcript file."

r-help

Eduardo Leoni
A: 

Check out the savehistory() command

Rob Hyndman
afaik savehistory does not save the output of the session, as desired by the Eytan.
Eduardo Leoni
A: 

Emacs is good, but for those of us with a vi preference there's the vim-r plugin at:

http://www.uft.uni-bremen.de/chemie/ranke/index.php?page=vim%5FR%5Flinux

It works brilliantly and has a tiny memory footprint.

A: 

I'm not sure yet how to answer an answer, but there is an updated version of Ranke's vim r-plugin called r-plugin2 available here. It seems more user-friendly and robust than the original.

Abhijit
A: 

hiiiiiiii ok best of luck

sunaina uppal