Re: [R] about get stdout from other program

From: Jan T. Kim <>
Date: Fri 01 Apr 2005 - 20:47:14 EST

On Fri, Apr 01, 2005 at 01:29:01AM +0000, Michael S wrote:

> if I want to use stdout from other language as my R program input ,which is
> the best way for design the API,using Pipe function or produce a temporary
> file,using scan function to read the file ?

For the scan function, it makes no difference whether you read from a pipe or a regular file, both are represented by connections in R.

Temporary files should be avoided where possible, as they introduce a source of data corruption that may remain unnoticed for quite some time.

If your external program can be run by just one command line, use a pipe, as in

    p = pipe("ls");
    scan(p, what = character(0));

Full filtering (i.e. if you need to write input into its stdin in addition to reading output from its stdout) is currently not supported by R. I've attempted to provide that, see

Best regards, Jan

 +- Jan T. Kim -------------------------------------------------------+
 |    *NEW*    email:                               |
 |    *NEW*    WWW:             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Sat Apr 02 01:19:26 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:58 EST