[R] executable R scripts

Greg Louis glouis at dynamicro.on.ca
Mon Jun 9 13:15:18 CEST 2003


On 20030608 (Sun) at 1735:14 -0700, John Zedlewski wrote:
> Hi, I'm a newbie trying to make an R program executable on UNIX, just like one 
> would write an executable perl script by putting "#!/usr/bin/perl" in the 
> first line, and so on.
> 
> It seems, though, that this would only work if I use the "BATCH" command to 
> tell R to execute the program in its first argument. This would have the 
> unfortunately side-effect of dumping all output to a file rather than stdout.
> 
> Additionally, I'd want to see only the results of "print" statements on 
> stdout, not all off R's output, just as when you source a script with 
> echo=FALSE.

I've seen the other replies, but thought this might be of interest too:
I hacked a hashbang wrapper so you can start an R script with
  #! /bin/sh /usr/bin/setR
and then invoke it with command-line arguments, which get passed to the
script in a character vector called argv.

See http://www.bgl.nu/~glouis/setR.html if you're interested.  I think
the version displayed has a couple of ampersand-lt; that need to be
changed to < if you use 'save as' rather than cutting and pasting.

-- 
| G r e g  L o u i s          | gpg public key: finger     |
|   http://www.bgl.nu/~glouis |   glouis at consultronics.com |
| http://wecanstopspam.org in signatures fights junk email |




More information about the R-help mailing list