简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM