Re: [R] scripts with littler

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon 08 Jan 2007 - 15:03:52 GMT

Looks like it will be possible to write scripts with R 2.5.0 using the new -f flag and file("stdin"). From https://svn.r-project.org/R/trunk/NEWS :

    o	Command-line R (and Rterm.exe under Windows) accepts the options
	'-f filename', '--file=filename' and '-e expression' to follow
	other script interpreters.  These imply --no-save unless
	--save is specified.

[..]

    o	file("stdin") is now recognized, and refers to the process's
	'stdin' file stream whereas stdin() refers to the console.
	These may differ, for example for a GUI console, an embedded
	application of R or if --file= has been used.



On 1/8/07, John Lawrence Aspden <news@aspden.com> wrote:
> Thanks, that's a really neat mechanism, ( I especially like the note to vim,
> which will save all my scripts having to end .R )
>
> Is there any way to get at the command line and stdio though?

>
> With littler I can do things like:
>
> #!/usr/bin/env r
>
> print(argv)
> t=read.table(file=stdin())
>
> so that I can write unix-style filters.
>
> Cheers, John.
>
>
>
> François Pinard wrote:
>
>
> > I usually do something like:
> >
> >
> > #!/bin/sh
> > R --slave --vanilla <<EOF
> >
> > R script goes here...
> >
> > EOF
> >
> > # vim: ft=r
> >
> >
> > If you need to search special places for packages, you may tweak
> > exported environment variables between the first and second line.
>
>
> --
> Contractor in Cambridge UK -- http://www.aspden.com
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue Jan 09 08:15:24 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 09 Jan 2007 - 06:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.