Piping stdin to R
Jeff and I wrote littler to do just this (and a few other things). Because of littler, I never looked that closely at Rscript -- but this should in principle work just fine.
Here is one of our early examples, using output from /bin/ls
(and a quick filter by awk
) to summarize file size:
edd@max:~/svn/littler/examples$ ls -l /boot/ | \ awk '!/^total/ {print $5}' | ./fsizes.r Min. 1st Qu. Median Mean 3rd Qu. Max. 24 130300 730700 3336000 4527000 14670000 The decimal point is 6 digit(s) to the right of the | 0 | 0000000000000011111111122777777777 2 | 777777777 4 | 555577777 6 | 8 | 10 | 12 | 5 14 | 24466677edd@max:~/svn/littler/examples$
Here the script fsizes.r
is just three lines:
edd@max:~/svn/littler/examples$ cat fsizes.r #!/usr/bin/r -ifsizes <- as.integer(readLines())print(summary(fsizes))stem(fsizes)edd@max:~/svn/littler/examples$