[R] Redirect Output to File and Screen in Parallel

David Winsemius dwinsemius at comcast.net
Fri Jan 29 18:57:59 CET 2016


> On Jan 29, 2016, at 12:59 AM, Manish MAHESHWARI <manishm at dbs.com> wrote:
> 
> Thanks Ulrik. The answer was there in the forumn. Apologies.
> 
> Also got an interesting solution - http://www.r-statistics.com/2010/05/helping-the-blind-use-r-by-exporting-r-console-to-word/

I'm pretty sure it was Tal's request, the responses and his posting of that link on Rhelp that I was remembering. 

There is also the possibility of accessing the "system variable": .Last.value

You cannot use it with sink("file.txt") since that command returns NULL and removes the temporarily saved value you might want to put in a file, but you can use `capture.output` which I see was recently given a 'split' option. I found this in the NEWS file which on my machine is at http://127.0.0.1:21567/doc/html/NEWS.html, but on your machine may have a different access method.

capture.output(.Last.value, file="save.txt")

Should place a text copy of the screen output resulting from the last console command into a file.

Best;
David.
> 
> Thanks,
> Manish
> 
> 
> From: Ulrik Stervbo [mailto:ulrik.stervbo at gmail.com]
> Sent: Friday, January 29, 2016 4:16 PM
> To: Manish MAHESHWARI
> Cc: r-help at r-project.org
> Subject: Re: [R] Redirect Output to File and Screen in Parallel
> 
> ?sink use the split = TRUE should do the trick
> 
> On Fri, 29 Jan 2016 at 08:44 David Winsemius <dwinsemius at comcast.net<mailto:dwinsemius at comcast.net>> wrote:
> 
>> On Jan 28, 2016, at 10:05 PM, Manish MAHESHWARI <manishm at dbs.com<mailto:manishm at dbs.com>> wrote:
>> 
>> Hi,
>> 
>> Using the sink we can redirect the output to sink files set as con.
>> However is there a way to do both - Have the Op printed on screen and also to the log file?
> 
> I think this has been asked and answered. Have you done any searching?
> 
>> 
>> Thanks,
>> Manish
>> CONFIDENTIAL NOTE:
>> The information contained in this email is intended only...{{dropped:11}}
>> 
>> ______________________________________________
>> R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
>> 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
> Alameda, CA, USA
> 
> ______________________________________________
> R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
> 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.
> CONFIDENTIAL NOTE:
> The information contained in this email is intended on...{{dropped:21}}



More information about the R-help mailing list