If you want the pretty-print effect of print(obj)
, but output to stderr, use capture.output
with file=stderr()
. This is a wrapper on sink()
as mentioned in another response.
capture.output( list(A=1,B=5:2), file=stderr())
The following goes to stderr
$A
[1] 1
$B
[1] 5 4 3 2