I used the following code -
msg <- file("ABC.txt", open="a")
out <- file("ABC.txt", open="a")
sink(msg, type="message")
sink(out, type="output")
write("write() to stderr", stderr())
write("write() to stdout", stdout())
and it works.
Thanks !!!
-Harmeet
On Fri, Jun 26, 2015 at 12:48 PM, Jianwen Luo <goutyl at 163.com> wrote:
> just use same file handle.
>
> ------------------------------
>
>
> *From:* My List <mylisttech at gmail.com>
> *Date:* 2015-06-26 15:37
> *To:* R-help <R-help at r-project.org>
> *Subject:* [R] Usage of sink()
> All:
>
> I have the following code segment.
>
> msg <- file("msg.txt", open="wt")
> out <- file("out.txt", open="wt")
> sink(msg, type="message")
> sink(out, type="output")
> write("write() to stderr", stderr())
> write("write() to stdout", stdout())
>
> This works fine, when I want the messages to goto mes.txt and output to
> out.xt.
>
> My desire is now to get to send both the output and messages( i.e stdout
> and stderr) to ONE file.
>
> How do I accomplish this?
>
> Thanks in Advance,
> - Harmeet
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
>
--
Thanks,
Harmeet
[[alternative HTML version deleted]]