Tue, 26 Sep 2006

Announcing 'littler'

Earlier today, Jeff announced our new toy r (aka 'littler') with this post on the r-help list.

What is 'littler'? We summarized it briefly in the post and on our respective or pages:

GNU R, a language and environment for statistical computing and graphics, provides a wonderful system for 'programming with data' as well as interactive exploratory analysis, often involving graphs.

Sometimes, however, simple scripts are desired. While R can be used in batch mode, and while so-called 'here' documents can be crafted, a long-standing need for a scripting front-end has often been expressed by the R Community.

littler (pronounced 'little R' and written 'r') aims to fill this need.

It can be used directly on the command-line just like, say, bc(1):

	$ echo 'cat(pi^2,"\n")' | r
	9.869604
http://ftp-master.debian.org/new.html Equivalently, commands that are to be evaluated can be given on the command-line
	$ r -e 'cat(pi^2, "\n")'
	9.869604
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		
And, last but not least, this (somewhat unwieldy) expression can be stored in a helper script:
	$ cat examples/fsizes.r
	#!/usr/bin/env r

	fsizes <- as.integer(readLines())
	print(summary(fsizes))
	stem(fsizes)
(where calling /usr/bin/env is a trick from Python which allows one to forget whether r is installed in /usr/bin/r, /usr/local/bin/r, ~/bin/r, ...)

A few examples are provided in the source directories examples/ and tests/.

At least one shortcoming already became apparent: by calling it r to not trample on the real R binary, we obviously overlooked that there are certain operating systems on which case is ignored -- ouch. So Mac users may have to install it as a littler binary.

Other comments, as seen in the mailing list thread, are mostly supportive.

littler can either be downloaded from either the Vanderbilt BioStat Wiki or my local archive. Also available is SVN access via

	svn  http://littler.googlecode.com/svn/trunk/ littler

Debian users shall get it via apt-get install littler as soon as it leaves Debian's NEW queue.

In the meantime, the configure && make && make install three-step works for us under any of Debian testing, Ubuntu Dapper, OS X, and with both R 2.3.1 and the pre-releases of R 2.4.0.

/computers/linux/debian/packages | permanent link