Skip to content
Prev 59009 / 398502 Next

Odd behaviour of R 2.00

On Sun, 14 Nov 2004, Hiroto Miyoshi wrote:

            
Without it, your logical matrix index contains NA.  What do you intend 
that to do?  Do you replace the corresponding element or not?  You don't 
know, so perhaps you set it to NA, whatever the rhs?  And do you use up a 
value on the rhs or not (not relevant if as here you are recycling a 
single value, except that you need to know how many times to recycle it)?

Prior to 2.0.0, R behaved inconsistently (both within itself and with S) 
with NA indices in assignments, so now we force the user to say what he 
intended.  This has picked up quite a number of errors.

I do think this would be cleaner and faster using a loop over columns, 
especially as you probably have factors in the data frame.  Read the code 
of "[<-.data.frame" if you don't see that.