[R] Getting sink to work with “message” on R 2.11.0 - what did I miss?

David Winsemius dwinsemius at comcast.net
Fri May 21 23:17:41 CEST 2010


On May 21, 2010, at 5:02 PM, Tal Galili wrote:

> Hi all,
>
> I am trying to use type message with sink, like this:
>
> sink("all.Rout", type="message")
> 1+3
>
> sink()
>
> readLines(con = "all.Rout")
>
> So to get the following output:
>
>> 1+3
> [1] 4
>
> Obviously this doesn't work.
>

What are you trying to do? The sink help page has two rather dire  
warnings about not using type="message",  and using type="output would  
give you what you ask:

 > sink("all.Rout", type="output")
 > 1+3
 >
 > sink()
 >
 > readLines(con = "all.Rout")
[1] "[1] 4"

The extra "[1]" and quotes are from the readLines function, not from  
all.Rout.

> I tried some variations (based on the explanations in the help) but am
> missing something on how to make it work.
>
> Any suggestions?
>
> (p.s: I need this so to help Faiz Rasool in his latest post)
>
> Thanks,
>
> Tal
-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list