1

I got the following error. Is there a way to saveRDS to stdout directly? Thanks.

R> saveRDS(1, stdout())
Error in saveRDS(1, stdout()) : 
  binary-mode connection required for ascii=FALSE
user1424739
  • 11,937
  • 17
  • 63
  • 152
  • If you look at `stdout()`, it's `mode = w` and `text = text`; to write a binary those need to be `mode = wb` and `text = binary`. You can set `ascii = TRUE` in `saveRDS` as the error suggests if you want, but that somewhat defeats the purpose. – alistaire Apr 13 '20 at 03:53
  • Is there a way to make stdout `mode = wb` and `text = binary`? – user1424739 Apr 13 '20 at 03:59
  • 1
    I don't think so, at least not short of diving into the C API. Why do you want to write a pile of binary to stdout? – alistaire Apr 13 '20 at 04:16
  • If the data can be written to stdout, then I can use `|` in shell and avoid saving any temp files in the analysis flow. – user1424739 Apr 13 '20 at 05:15
  • 1
    Related to: https://stackoverflow.com/questions/7422575/how-to-write-raw-type-bytes-to-stdout – MrFlick Apr 13 '20 at 06:38

0 Answers0