[R] executable R scripts
Dirk Eddelbuettel
edd at debian.org
Mon Jun 9 03:52:04 CEST 2003
On Sun, Jun 08, 2003 at 05:35:14PM -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.
This is not currently supported, but with some luck may be supported in a
later version of R.
> 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.
My personal favourite currently is to arrange everything (loading of
package, code, ...) in a file which I can read with source() from within R.
Then
$ echo "source(\"foo.R\") | R --slave
works quite well, you can redirect etc. Works on windows/cygwin too using
Rterm.exe.
> 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 think the above fits that bill.
> This seems like it would be a pretty common problem, but I haven't found any
> explanations in the docs. Does somebody have a sample script that I could
> look at for advice? Or should I just bite the bullet and write a wrapper
> shell script?
That's where the above leads to as well.
Dirk
--
Don't drink and derive. Alcohol and analysis don't mix.
More information about the R-help
mailing list