How do I log an R session to a file?

James Howard picture James Howard · Mar 9, 2012 · Viewed 27.6k times · Source

Other than through redirection, which captures an entire session, is there a way to start and stop logging during an R session? To clarify, I am looking for something similar to the log using command in Stata.

Answer

Dirk Eddelbuettel picture Dirk Eddelbuettel · Mar 9, 2012

Do you know about sink() in base R ?

There are also some logging packages on CRAN: logging, log4r and possibly more.

Lastly, Emacs user have ESS and its transcript mode. You can save your session as a log, and in general, the 'work from file and execute from the file' approach builds a (partial, commands-only) log as you work.