[R] Zero Index Origin?

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Mar 31 10:28:56 CEST 2004


Much of R is itself written in R, so you cannot possibly change something 
as fundamental as this.  Further, index 0 has a special meaning that you 
would lose if R have 0-based indexing.

However, the R thinking is to work with whole objects (vectors, arrays, 
lists ...) and you rather rarely need to know what numbers are in an index 
vector.  There are usages such as 1:n, and those are quite often wrong: 
they should be seq(length=n) or seq(along=x) or some such, since n might 
be zero.  If you are writing code that works with single elements, you are 
probably a lot better off writing C code to link into R (and C is 
0-based ...).

On Wed, 31 Mar 2004, Bob Cain wrote:

> 
> I'm very new to R and utterly blown away by not only the 
> language but the unbelievable set of packages and the 
> documentation and the documentation standards and...
> 
> I was an early APL user and never lost my love for it and in 
> R I find most of the essential things I loved about APL 
> except for one thing.  At this early stage of my learning I 
> can't yet determine if there is a way to effect what in APL 
> was zero index origin, the ordinality of indexes starts with 
> 0 instead of 1.  Is it possible to effect that in R without 
> a lot of difficulty?
> 
> I come here today from the world of DSP research and 
> development where Matlab has a near hegemony.  I see no 
> reason whatsoever that R couldn't replace it with a _far_ 
> better and _far_ less idiosyncratic framework.  I'd be 
> interested in working on a Matlab equivalent DSP package for 
> R (if that isn't being done by someone) and one of the 
> things most criticized about Matlab from the standpoint of 
> the DSP programmer is its insistence on 1 origin indexing. 
> Any feedback greatly appreciated.
> 
> 
> Thanks,
> 
> Bob
> 

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