Skip to content

R/S indexing difference

3 messages · Brian Ripley, Peter Dalgaard

#
Is this intentional?

R:
[1] -4  2 -6  4  5  6  7

so NAs are treated as FALSE

S+6.1:
Warning messages:
  Replacement length not a multiple of number of elements to
	replace in: x[c(1, NA, 3)] <-  - (4:6)
[1] -4  2 -5  4  5  6  7

and NAs are ignored.
#
ripley@stats.ox.ac.uk writes:
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...
1 day later
#
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: