Skip to content
Prev 166354 / 398502 Next

NAs are not allowed in subscripted assignments

Browse[1]> j <- c(1,2,NA)
Browse[1]> j[j==1][-1]
[1] NA
Browse[1]> j[j==1][-2]
[1] 1
Browse[1]> j[j==1][-2] <- 2
Error during wrapup: NAs are not allowed in subscripted assignments

As far as I can see, I have no NA in the lhs (not after the second
subscript anyway).
Besides, I have a single value on the rhs, so it should be allowed to
have NAs in the lhs, according to help(Extract).

What am I missing?
I can see no ambiguite as to what the result of those commands should be
(j == c(2,2,NA)).