[R] New project: littler for GNU R
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Sep 27 05:45:39 CEST 2006
I think this is quoted out of context. I was referring to Duncan's post
which shows an example of piping R code.
On 9/26/06, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> 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 at stats.uwo.ca> wrote:
> | > 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
>
More information about the R-help
mailing list