Skip to content
Prev 28674 / 63421 Next

Out of bounds negative index

On 5/2/2008 3:23 PM, Vincent Goulet wrote:
Looks to me like a documentation error.  I would expect from that 
description that executing

 > x <- 1:5
 > x[7]
[1] NA
 > x[-7]
[1] 1 2 3 4 5

would have given an error on x[-7], but clearly it didn't.  This 
behaviour appears to have started with 2.6.0; 2.5.1 gives the error.  I 
don't see a NEWS entry about it...but revision r42123 says

  Changed the behaviour of out-of-bounds negative
  subscripts to match that of S.  Such values are
  now ignored rather than tripping an error.

so apparently it was intentional.

Duncan Murdoch