Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

Re: [R] New project: littler for GNU R

Dirk Eddelbuettel

2006-09-26

Replies:


On 26 September 2006 at 22:17, Gabor Grothendieck wrote:
| The real problem is that one wants to pipe the data in, not the
| R source. The idea is that one successively transforms the
| data in successive elements of the pipeline.

But that is what our filesize example does::

| On 9/26/06, Duncan Murdoch <murdoch@(protected):
| > On 9/26/2006 1:04 PM, Jeffrey Horner wrote:
[...]
| > >   But unlike bc(1), GNU R has a vast number of statistical
| > >   functions. For example, we can quickly compute a summary() and show
| > >   a stem-and-leaf plot for file sizes in a given directory via
| > >
| > >       $ ls -l /boot | awk '!/^total/ {print $5}' | \
| > >          r -e 'fsizes <- as.integer(readLines());
| > >            print(summary(fsizes)); stem(fsizes)'
| > >         Min. 1st Qu. Median   Mean 3rd Qu.   Max.
| > >          13   512 110100 486900 768400 4735000
| > >       Loading required package: grDevices
| > >
| > >        The decimal point is 6 digit(s) to the right of the |
| > >
| > >        0 | 00000000000000000011112223
| > >        0 | 5557778899
| > >        1 | 112233
| > >        1 | 5
| > >        2 |
| > >        2 |
| > >        3 |
| > >        3 |
| > >        4 |
| > >        4 | 7

Data to be processed on stdin, command via -e 'some long expression'.

To make it simpler, here is a somewhat useless example of r piping into r
(which I've indented for readability):

$ r -e 'set.seed(42); sapply(rnorm(5),function(x) cat(x,"\n"))' | \
    r -e 'cat(sum(abs(as.numeric(readLines()))), "\n")'
3.335916

Isn't that something where, to quote you, "one wants to pipe the data in, not
the R source" ?

Dirk

--
Hell, there are no rules here - we're trying to accomplish something.
                                -- Thomas A. Edison

______________________________________________
R-help@(protected)
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.
©2008 r-help.com - Jax Systems, LLC, U.S.A.