Vadim Ogranovich
2005-Apr-03 23:40 UTC
[Rd] Error: NAs are not allowed in subscripted assignments: change from R.1.9
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),] = xError: NAs are not allowed in subscripted assignments # it does work for a vector> x = matrix(1, 2, 2); x[c(1,NA),] = 1Is this change intentional? There seems to be nothing about it in the release notes. Thanks, Vadim> version_ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 0.1 year 2004 month 11 day 15 language R
Peter Dalgaard
2005-Apr-03 23:49 UTC
[Rd] Error: NAs are not allowed in subscripted assignments: change from R.1.9
"Vadim Ogranovich" <vograno@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@biostat.ku.dk) FAX: (+45) 35327907