[Rd] Rscript on Windows

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri 26 Jan 2007 - 04:58:51 GMT


On UNIX one can use #! notation. It would be nice to be able to do something similar on Windows.

This could be done by giving Rscript the capability of skipping over the first few
lines. For example, there might be a --skip=n argument or perhaps Rscript would skip over any consecutive leading lines that begin with @ in the R file since that
cannot be syntactically correct R but does have meaning to Windows batch, namely, it means do not display the line beginning with @ (but still run it). For example, if we implement the @ idea then a sample 3 line file called grep.bat might look like this:

@Rscript grep.bat %1

   for(L in grep(commandArgs(TRUE), readLines(file("stdin")), value = TRUE))

      cat(L, "\n", sep = "")

and then we would run it as a Windows batch file like this from the Windows console to find all lines with the word target:

   grep target < myfile.txt

or if we implemented --skip it might look like this:

@Rscript --skip=1 grep.bat %1

   for(L in grep(commandArgs(TRUE), readLines(file("stdin")), value = TRUE))

      cat(L, "\n", sep = "")



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Jan 26 16:01:36 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 Fri 26 Jan 2007 - 15:31:14 GMT.

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