3

Is it possible to merge and split the standard R connections? I mean:

1) to split (duplicate) a single connection into two connections (files for example). This would mean to say "everything sent to this connection will be sent to these two other connections". For example, that could serve as a workaround for the "cannot split the message connection" error:

conn <- file("log.txt", open = "wt")
sink(conn, type = "message", split = TRUE)
#error: cannot split the message connection

which could then be solved by redirecting the conn connection into two other connections (e.g. stdout and a file, or two different files).

2) to merge two different connections into a single one. This would mean to say "merge all text lines in two different connections into a single connection, in chronological order".

Both merge and split of connections would then very simply solve e.g. problems like this: Log stdout + stderr and stderr simultaneously in R.

Tomas
  • 57,621
  • 49
  • 238
  • 373

0 Answers0