[R] writing R shell scripts?

Mike Miller mbmiller at taxa.epi.umn.edu
Wed Nov 9 02:39:09 CET 2005


Many thanks for the suggestions.  Here is a related question:

When I do things like this...

echo "matrix(rnorm(25*2),c(25,2))" | R --slave --no-save

...I get the desired result except that I would like to suppress the 
"[,1]" row and column labels so that only the values go to stdout.  What 
is the trick to making that work?

By the way, I find it useful to have a script in my path that does this:

#!/bin/sh
echo "$1" | /usr/local/bin/R --slave --no-save

Suppose that script was called "doR", then one could do things like this 
from the Linux/UNIX command line:

# doR 'sqrt(35.6)'
[1] 5.966574

# doR 'runif(1)'
[1] 0.8881654

Which I find to be handy for quick arithmetic and even for much more 
sophisticated things.  I'd like to get rid of the "[1]" though!

Mike

-- 
Michael B. Miller, Ph.D.
Assistant Professor
Division of Epidemiology and Community Health
and Institute of Human Genetics
University of Minnesota
http://taxa.epi.umn.edu/~mbmiller/




More information about the R-help mailing list