[R] Can R read data from stdin?
Hayashi Soichi - shayas
Soichi.Hayashi at acxiom.com
Fri Jul 9 23:41:48 CEST 2004
Thanks! That's what I was wanted to know.
Also, is there a similar way I can do read.table from a pipe?
For example, if there is a command that I am running to generate the
datasource, I want to read that data as it comes..
From: Aaron J. Mackey [mailto:amackey at pcbi.upenn.edu]
Sent: Friday, July 09, 2004 4:10 PM
To: Tony Plate
Cc: R-help at stat.math.ethz.ch; Hayashi Soichi - shayas
Subject: Re: [R] Can R read data from stdin?
I think the original poster wanted to read data from stdin, not execute
an entire script from stdin; this works on many UNIX-like systems:
d <- read.table("/dev/stdin", header=F);
Otherwise, for code, you can simply pipe (or redirect) to R from the
% R --vanilla --slave < input > outfile
On Jul 9, 2004, at 4:34 PM, Tony Plate wrote:
> The easiest way would probably be to do the hack of creating a
> temporary file to hold stdin, then call R to process that file. That
> would be easy to do in a shell script.
> If this really won't suffice, this older message might lead to
> something useful:
>> Rd] R scripting patches for R-1.8.0
>> Neil McKay mckay at repsac.gmr.com
>> Thu Oct 16 20:30:20 MEST 2003
>> Previous message: [Rd] data() misbehaving inside a function
>> Next message: [Rd] R scripting patches for R-1.8.0
>> Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>> I've updated my scripting patches to R-1.8.0. These patches
>> allow you to write shell scripts in R (at least on *nix systems)
>> by putting
>> #!/path/to/R.bin --script
>> on the first line of the script file. If you're interested
>> in the patches, e-mail me at
>> mckay at gmr.com
>> Neil D. McKay, Mail Code 480-106-359 Phone: (586)986-1470
>> Manufacturing Systems Research Lab FAX: (586)986-0574
>> GM Research & Development Center Internet e-mail: mckay at
>> 30500 Mound Road
>> Warren, Mich. 48090
> At Friday 02:17 PM 7/9/2004, Hayashi Soichi - shayas wrote:
>> Is there anyway I can write a script which feed input datasource from
>> and let R process it (maybe frequency report) then output the report
>> I can't seem to find much info on documentation or FAQ on this topic.
>> Soichi Hayashi
The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.
More information about the R-help