Re: [R] Use R in a pipeline as a filter

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu, 07 Jun 2007 14:15:47 +0100 (BST)

This is one of the things that 'Rscript' is for: see 'An Introduction to R' (section B.4 in the HTML version,
http://cran.r-project.org/doc/manuals/R-intro.html#Scripting-with-R).

You haven't even told us your version of R or OS (see the posting guide): you need R >= 2.5.0 for this. But your 'example' would be

./generate-data | Rscript Script.R | ./further-analyse-data > result.dat

On Thu, 7 Jun 2007, mw-u2_at_gmx.de wrote:

> Hi,
>
> how can I use R in a pipline like this
>
> $ ./generate-data | R --script-file=Script.R | ./further-analyse-data > result.dat
>
> Assume a column based output of ./generate-data, e.g. something like:
> 1 1 1
> 2 4 8
> 3 9 27
> 4 16 64
>
> The R commands that process the data should come from Script.R and
> should print to stdout (Script.R could for example calculate the square
> of every entry or calculate the mean of the columns, ...)
>
> The output should be printed to stdout, such that further-analyse-data
> can use the output.
>
> Can some R expert code that for me please? I would be very happy. I am
> also happy about information how to do that myself although I dont think
> I know enough to do that myself.
>
> Thank you for your consideration,
>
> Micha
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 07 Jun 2007 - 13:27:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 07 Jun 2007 - 13:31:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.