[R] write console ouptut to file AND view in console

Henrik Bengtsson henr|k@bengt@@on @end|ng |rom gm@||@com
Wed Mar 23 22:36:21 CET 2022


I think adding argument split=TRUE will do what you want.

FYI, it's a bit risky to rely on sink type="message" (standard error).
Contrary to "output" sinks, there can only be one "message" sink
active at any time, and whoever grabbed it last owns it going forward.
I'd say it can only be the end-user who can use this sink at the top
level, but it must not be used in packages (which then would steal it
from the end-user).

/Henrik


On Wed, Mar 23, 2022 at 1:47 PM nevil amos <nevil.amos using gmail.com> wrote:
>
> I know I can write console output to a file:
> my_log <- file("my_log.txt")
>   sink(my_log, append = TRUE, type = "output")
>   sink(my_log, append = TRUE, type = "message")
>
> Is there any way to do this while still having the output display in the
> console at the same time
>
> thanks
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using 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.



More information about the R-help mailing list