[Rd] Re: negative indices and NAs in R 1.9.0.alpha

Martin Maechler maechler at stat.math.ethz.ch
Mon Mar 22 18:20:25 CET 2004


>>>>> "JensOe" == Jens Oehlschlägel <joehl at web.de>
>>>>>     on Mon, 22 Mar 2004 18:03:08 +0100 writes:

    JensOe> I was notfied that my package ref fails R CMD CHECK
    JensOe> under 1.9.0 Alpha.  I downloaded the windows version
    JensOe> of 1.9.0 Alpha (dated 2004-03-17) and package ref
    JensOe> passes R CMD CHECK without any complaints.

    JensOe> The daily checks suggest the problem arises in
    JensOe> example(optimal.index)

    JensOe> Error in identical(l[i], l[optimal.index(i, n =
    JensOe> length(l), strict = FALSE)]) : only 0's may mix with
    JensOe> negative subscripts

    JensOe> where negative subscripts are mixed with NAs (which
    JensOe> was legal in versions prior 1.9.0).

    JensOe> Is it an intended change not to allow NA mix with
    JensOe> negative subscripts any longer?  (I did not find any
    JensOe> hint in NEWS)

A shorter version is

  > x <- 1:9; x[-c(-1,NA,3:5)]
  Error: only 0's may mix with negative subscripts

which used to simply give

  > x <- 1:9; x[-c(1,NA,3:5)]
  [1] 2 6 7 8 9

and is the same if there was no NA in the index -- without a warning;
not necessarily desirable as well.

---------

However, the current NEWS  file does say


    o   Negative subscripts that were out of range or NA were not handled 
        correctly.


R 1.9.0 (beta)'s behavior seems to match the one of S-plus here,
but that alone is not convincing enough IMO.

Regards, Martin



More information about the R-devel mailing list