How do you sink input and output to a text file in R?

Posted by Jeromy Anglim on Stack Overflow See other posts from Stack Overflow or by Jeromy Anglim
Published on 2010-06-06T07:19:15Z Indexed on 2010/06/06 7:22 UTC
Read the original article Hit count: 319

Filed under:

How do you sink both the console input and the console output to a text file? Take the following code:

sink("temp.txt")
1:10
sink()

It will write a text file that looks like this:

[1]  1  2  3  4  5  6  7  8  9 10

But how do I create a text file that looks like this:

>   1:10
 [1]  1  2  3  4  5  6  7  8  9 10

I've looked at ?sink and searched R-help.

© Stack Overflow or respective owner

Related posts about r