[R] input arguments in a file into rscript

Duncan Murdoch murdoch.duncan at gmail.com
Sun Oct 14 00:46:02 CEST 2012


On 12-10-13 5:16 PM, Wensui Liu wrote:
> dear listers,
>
> with "rscript", i know how to feed arguments by command line directly,
> e.g. "Rscript test.r 10 20". however, if i saved all arguments in a
> file, how do i make rscript to take arguments in this file?  "Rscript
> test.r < input.txt" doesn't seem to work for me.
> (ps: i am using windows)

You should be able to read them from the file, e.g.

readLines("input.txt")

will get all the lines from that file.  I expected stdin() to work with 
the redirection, but it doesn't appear to work in Windows.  Not sure if 
that's a bug or not...

Duncan Murdoch




More information about the R-help mailing list