[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-help
Subject:    Re: [R] About "=" in command line in windows.
From:       Prof Brian Ripley <ripley () stats ! ox ! ac ! uk>
Date:       2007-08-31 15:39:35
Message-ID: Pine.LNX.4.64.0708311620530.5182 () gannet ! stats ! ox ! ac ! uk
[Download RAW message or body]

On Fri, 31 Aug 2007, Vladimir Eremeev wrote:

> It seems, I don't understand something, or there is a bug in R.

A limitation in command-line parsing which is Windows-specific.

Don't use -e for complex expressions, as the quoting is getting removed by 
your shell.  In Windows both the shell (and it matters which shell) and 
the (compiled C) executable parse the command line, and that leads to 
surprises as in your (1).  At that point the rule about NAME=VALUE on the 
command line meaning 'set environment variable NAME' comes into play.

We could try harder (and maybe one day we will), but this really is 
'quoting hell' and there is no hardship in using alternatives such as

% cat > test.R
mean(x=1:3)
^D
% rscript test.R

and

% echo "mean(x=1:3)" | rscript -


> 
> I have made some experiments after my yesterday post about using "=" with -e
> switch to the Rscript.
> 
> Now, I've found:
> 
> (1)
> C:\users\wl\trainings\r>rscript --verbose -e "mean(x=1:3)"
> running
> 'C:\Program Files\R\bin\Rterm.exe --slave --no-restore -e mean(x=1:3)'
> 
> Error in -args : invalid argument to unary operator
> Execution halted
> 
> (2)
> C:\users\wl\trainings\r>Rterm --slave --no-restore -e "mean(x=1:3)"
> 
> Nothing is printed on the console, but the window appears, saying "R for
> Windows terminal front-end has encountered a problem and needs to close. We
> are sorry for the inconvenience."
> 
> (3)
> C:\users\wl\trainings\r>rscript --verbose -e "mean(1:3)"
> running
> 'C:\Program Files\R\bin\Rterm.exe --slave --no-restore -e mean(1:3)'
> 
> [1] 2
> 
> (4)
> C:\users\wl\trainings\r>Rterm.exe --slave --no-restore -e "mean(1:3)"
> [1] 2
> 
> (5)
> C:\users\wl\trainings\r>Rterm.exe --slave --no-restore -e 'mean(1:3)'
> [1] "mean(1:3)"
> 
> Points (1) and (2) don't seem normal to me, however, I don't see, what I am
> doing wrong.
> I use windowsXP Pro, my colleague uses windows 2000 and reports the same
> problems.
> My sessionInfo():
> 
> > sessionInfo()
> R version 2.5.1 Patched (2007-08-19 r42614)
> i386-pc-mingw32
> 
> locale:
> LC_COLLATE=Russian_Russia.1251;LC_CTYPE=Russian_Russia.1251;LC_MONETARY=Russian_Russia.1251;LC_NUMERIC=C;LC_TIME=Russian_Russia.1251
>  
> attached base packages:
> [1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"
> [7] "base"
> 
> 
> 

-- 
Brian D. Ripley,                  ripley@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

______________________________________________
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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic