[R] Use R in a pipeline as a filter
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Jun 7 15:15:47 CEST 2007
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
More information about the R-help
mailing list