Re: [R] How to save & play back an entire R session?
> Saving the session history is indeed easy (savehistory). > The problem is the playback. I didn't find a reliable method. Well, you could simply source() the .Rhistory file (or the file you saved under some other name). But as you already poitned out - it's better to go with scripts to begin with. cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ __ R-help@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.
Re: [R] How to save & play back an entire R session?
Thank you all. I experimented with the various suggestions you proposed. Saving the session history is indeed easy (savehistory). The problem is the playback. I didn't find a reliable method. Plus, I now realize that the very idea of playing back a saved session is, in general, a bad one, since such a session may have made changes to disk. So I'll go with Rob's idea of working indirectly from a script that I keep re-sources. Thanks again! Roy __ R-help@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.
Re: [R] How to save & play back an entire R session?
To just save a copy of all the commands issued you can use the savehistory function (this is documented on the same page as history, so David's answer would have lead you there as well). If you want to save all the outputs from you session you can use the sink function. You can save a combination of the inputs and outputs using the R2HTML package or the TeachingDemos package (see ?txtStart in the later). For both of those you need to start recording and end recording (and specify if you want a graph saved). The txtStart option also gives the option to save a script file of all the commands (similar to saveHistory, but as you go along rather than after the fact) that can be rerun later using source. But it is generally better to write a script file and run from that, then you have control over what goes into the file, do you really want to rerun all calls to help and mistakes? You can run a whole script from a file using the source function, or there are various editors that will send lines or blocks to be evaluated (the R gui on windows does this, also emacs, tinn-R, vim, and probably others that I missed). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Roy Shimizu > Sent: Thursday, December 16, 2010 7:44 AM > To: r-help@r-project.org > Subject: [R] How to save & play back an entire R session? > > I know that at the end of an R session I'm given the option to save > the current *state* of the session. > > But I would like to save the entire sequence of inputs that took place > during the session, so that I can play them back later, and not only > be left in the same state I was at the time of saving the session, but > be able to see the entire history of the session (inputs and outputs). > (This is somewhat reminiscent of what can be done with Mathematica > notebooks, although not exactly, since, with Mathematica notebooks, > one doesn't necessarily save the original inputs.) > > Does anyone know how to achieve this? > > Thanks! > > Roy > > __ > R-help@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. __ R-help@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.
Re: [R] How to save & play back an entire R session?
Roy, In addition to previous responses, another way of achieving this is to only work from scripts. I rarely type anything directly into R, just edit scripts in an editor and then execute the entire script (or parts of the script) from within the editor. This way of working provides backup, e.g. if something goes wrong in R. Typing directly into the R session is still useful to quickly try something or help questions. Regards, Rob On Dec 16, 2010, at 7:06 AM, David Winsemius wrote: > > On Dec 16, 2010, at 9:43 AM, Roy Shimizu wrote: > >> I know that at the end of an R session I'm given the option to save >> the current *state* of the session. >> >> But I would like to save the entire sequence of inputs that took place >> during the session, so that I can play them back later, and not only >> be left in the same state I was at the time of saving the session, but >> be able to see the entire history of the session (inputs and outputs). >> (This is somewhat reminiscent of what can be done with Mathematica >> notebooks, although not exactly, since, with Mathematica notebooks, >> one doesn't necessarily save the original inputs.) >> >> Does anyone know how to achieve this? >> > > ?history > >> Thanks! >> >> Roy >> >> __ >> R-help@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. > > David Winsemius, MD > West Hartford, CT > > __ > R-help@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. __ R-help@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.
Re: [R] How to save & play back an entire R session?
On Dec 16, 2010, at 9:43 AM, Roy Shimizu wrote: I know that at the end of an R session I'm given the option to save the current *state* of the session. But I would like to save the entire sequence of inputs that took place during the session, so that I can play them back later, and not only be left in the same state I was at the time of saving the session, but be able to see the entire history of the session (inputs and outputs). (This is somewhat reminiscent of what can be done with Mathematica notebooks, although not exactly, since, with Mathematica notebooks, one doesn't necessarily save the original inputs.) Does anyone know how to achieve this? ?history Thanks! Roy __ R-help@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. David Winsemius, MD West Hartford, CT __ R-help@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.
Re: [R] How to save & play back an entire R session?
On 16/12/2010 9:43 AM, Roy Shimizu wrote: I know that at the end of an R session I'm given the option to save the current *state* of the session. But I would like to save the entire sequence of inputs that took place during the session, so that I can play them back later, and not only be left in the same state I was at the time of saving the session, but be able to see the entire history of the session (inputs and outputs). (This is somewhat reminiscent of what can be done with Mathematica notebooks, although not exactly, since, with Mathematica notebooks, one doesn't necessarily save the original inputs.) Does anyone know how to achieve this? history(Inf) will display all inputs. You could save those and cut and paste them to run again. In the Windows console (and others?) you can save the complete contents. This is just the text output. You can re-run pieces using cut and "Paste commands only" (which I think is a Windows-only option). Duncan Murdoch __ R-help@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.