From ripley@stats.ox.ac.uk  Fri Feb  7 22:19:02 2003
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Fri Feb  7 22:19:02 2003
Subject: [Rd] R/S indexing difference
In-Reply-To: <x2bs1pk9c4.fsf@biostat.ku.dk>
Message-ID: <Pine.LNX.4.44.0302072113170.25989-100000@gannet.stats>

The S version is at least documented (p.157 of the Green book).  I can't 
find any documentation of the R version, not even in the so-called
`R Language Definition': is there one?

On 6 Feb 2003, Peter Dalgaard BSA wrote:

> ripley@stats.ox.ac.uk writes:
> 
> > Is this intentional?
> > 
> > R:
> > > x <- 1:7
> > > x[c(1, NA, 3)] <- -(4:6)
> > > x
> > [1] -4  2 -6  4  5  6  7
> > 
> > so NAs are treated as FALSE
> > 
> > S+6.1:
> > > x <- 1:7
> > > x[c(1, NA, 3)] <- -(4:6)
> > Warning messages:
> >   Replacement length not a multiple of number of elements to
> > 	replace in: x[c(1, NA, 3)] <-  - (4:6)
> > > x
> > [1] -4  2 -5  4  5  6  7
> > 
> > and NAs are ignored.
> 
> Hmm. Neither of the options look too safe to me...
> 
> A 3rd bit of logic would say that you should get a vector of
> 7 NAs since you're asking to put the -5 into an unknown location...
> 
> 

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



[Rd] R/S indexing difference
ripley@stats.ox.ac.uk