[Rd] Error: NAs are not allowed in subscripted assignments: change from R.1.9

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Apr 3 23:49:15 CEST 2005


"Vadim Ogranovich" <vograno at evafunds.com> writes:

> Hi,
> 
> There seems to be a change in 2.0.1 in the workings of subscript
> assignments with missing values.
> 
> 
> # This is R.2.0.1
> 
> # assignment w/ missing index doesn't work when right-hand-side is a
> matrix. It did work in 1.9.1
> > x = matrix(1, 2, 2); x[c(1,NA),] = x
> Error: NAs are not allowed in subscripted assignments
> # it does work for a vector
> > x = matrix(1, 2, 2); x[c(1,NA),] = 1
> 
> Is this change intentional? There seems to be nothing about it in the
> release notes.

Yes, and oh yes there is, for the version where it changed, in ONEWS:

    o   Subassignments involving NAs and with a replacement value of
        length > 1 are now disallowed.  (They were handled
        inconsistently in R < 2.0.0, see PR#7210.)  For data frames
        they are disallowed altogether, even for logical matrix indices
        (the only case which used to work).


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-devel mailing list