Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I log an R session to a file?

Tags:

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.

like image 967
James Howard Avatar asked Mar 09 '12 15:03

James Howard


People also ask

How do you save a log in R?

You can also save the entire R console screen within the GUI by clicking on "Save to File..." under the menu "File." This saves the commands and the output to a text file, exactly as you see them on the screen.

What is log file in R?

The logr package helps create log files for R scripts. The package provides easy logging, without the complexity of other logging systems. It is designed for analysts who simply want a written log of their program execution. The package is implemented as a wrapper to the base R sink() function.

How do you save an output in R?

Saving your workspace is how you save your data within R. Click on the Console window, go to the File menu and select “Save Workspace...”. In another R session, you open this workspace with the “Load Workspace...” command. To save everything that has scrolled past on the Console window, click on the Console window.


1 Answers

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.

like image 82
Dirk Eddelbuettel Avatar answered Sep 19 '22 12:09

Dirk Eddelbuettel