Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save the output of an r script including its commands

Tags:

output

r

sink

I want to save a part of my r script output including the commands into a text file. I know sink() but it does not include the commands or I could not find a specific option to do that.

Is there any possibility to capture the commands and its ouput within an r session. Simply write an Rmd or capture the output within the console is not the solution at the moment.

like image 455
Markus Graf Avatar asked Feb 07 '23 21:02

Markus Graf


1 Answers

You are probably looking for the TeachingDemos package. Documentation can be found here.

Example:

library(TeachingDemos)

txtStart("test.txt")
# Your code
txtStop()

This should write both your command input and output to a file called test.txt.

like image 82
Patrick Kostjens Avatar answered Feb 16 '23 02:02

Patrick Kostjens