is.na(v)<-b (was: Re: [R] Beginner's query - segmentation fault)

Paul Lemmens P.Lemmens at nici.kun.nl
Tue Oct 14 17:10:03 CEST 2003


By accident I'm also toying around with NA's, so I started reading up on 
this thread but failed to find a 'concluding' remark or advice. As a naive 
R user I would have loved to see a comment "do it like this".

The prevailing opinion seemed to be that is.na() might be better (safer) 
but x <- NA is much clearer to understand. Can I relatively safely use the 
easy form, or is it better to remember (the hard way) the safer version? 
Has the discussion continued privately or just stopped here?

Personally I still find the fragments below (taken from the thread) very 
counter intuitive, not to say scary.

x <- 1:10
is.na(x) <- 1:5

and

is.na(x) <- FALSE


It's very hard to understand what happens (as layman) because the 
assignment seems to reverse in meaning in the first example (actually 
taking indices 1:5 of x and assigning those the value NA) whereas in the 
second case it's not obvious what happens to x: will it get the value FALSE 
or will the original value remain(*).

IMHO the <- NA construct is much easier to understand and should be made 
safe in all possible situations (whatever the underlying safety problem or 
other difficulties might be).


kind regards,
Paul

(*) Such a remark will probably lead to some kind of reprimand because it's 
probably somewhere within the 10e6 manual pages but I'm trying my luck here.


-- 
Paul Lemmens
NICI, University of Nijmegen              ASCII Ribbon Campaign /"\
Montessorilaan 3 (B.01.03)                    Against HTML Mail \ /
NL-6525 HR Nijmegen                                              X
The Netherlands                                                 / \
Phonenumber    +31-24-3612648
Fax            +31-24-3616066




More information about the R-help mailing list