user11980328
user11980328

Reputation: 93

How to readRDS from stdin?

I try to use the following command to read an RDS file. But it doesn't work. My OS is Mac OS X.

$ lr -e "readRDS(file('stdin'))" < /tmp/x.rds 
Error in readRDS(file("stdin")) : unknown input format
$ lr -p -e "readRDS('/dev/stdin')" < /tmp/x.rds 
Error in readRDS("/dev/stdin") : error reading from connection

But this works.

$ lr -p -e "readRDS('/tmp/x.rds')"
  x  y
1 1 11
2 2 12
3 3 13

Does anybody know how to readRDS from stdin? Thanks.

Upvotes: -1

Views: 190

Answers (1)

user12728748
user12728748

Reputation: 8506

It works for me (on linux, using littler 0.3.9 on R-devel) using '/dev/stdin' instead of 'stdin'; so try:

lr -p -e "print(readRDS('/dev/stdin'))" < /tmp/x.rds

Upvotes: 0

Related Questions