[R] R CMD BATCH character limit?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Feb 2 11:39:15 CET 2005
On Tue, 1 Feb 2005, Hsiu-Khuern Tang wrote:
> Is there a limit on the number of characters in an invocation like
>
> R CMD BATCH --opt1=val1 --opt2=val2 ... --save-to=C:\very\long\string ..\R\script.R
>
> ?
Yes, but that is not a valid invocation of R.
> I am running R 2.0.1 on Windows XP, and when running a long BATCH
> command (about 400--500 characters) the last option gets mangled, as can
There is a Windows limit on the length of command lines, and I believe you
have hit it. It looks like R.exe/Rcmd.exe were written assuming it is
MAX_PATH, hence about 260, which it used to be in Win95.
You could use
rterm --args --opt1=val1 --opt2=val2 ... --save-to=C:\very\long\string < foo > bar
instead: BATCH is just a convenient shorthand (and see the rw-FAQ for the
details).
Shells also have limits, so check this for the one you used.
> be seen from a warning in script.Rout that looks like this:
>
> WARNING: unknown option
> +--save-to=C:\very\long\str..\R\script.Rout
>
> Note that "string" is truncated to "str" _and_ concatenated with the
> implicit batch output file "..\R\script.Rout". (The "unknown option"
> warning is expected; I am just using commandArgs() within the script to
> pick out the arguments.)
>
> I have tried specifying --args before the options, with the same result,
> except that the truncation appears earlier.
--args would be needed for this to make any sense.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list