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

Simon Fear Simon.Fear at synequanon.com
Wed Oct 15 11:08:41 CEST 2003


I think the thread ended up with several people (not only me)
feeling certain they didn't like `is.na<-` but with the 
developers defending it and me not really understanding
why.

Uwe Ligges was going to come up with an example of
`<- NA` going wrong (sorry Brian R, I mean behaving
unexpectedly), but never did, and I think the problem
has been fixed. It was apparently a problem with assigning
NAs to an existing factor, but the code for `[<-.factor`
looks pretty robust to me [not that I'm at all qualified to say
that, be warned]. Interestingly, at some point both methods
for `is.na<-` perform this operation: x[value] <- NA. Ahem.

By the way, `is.na(x) <- FALSE` will leave x unchanged (including
leaving it as NA ! how bad is that ?!)

> -----Original Message-----
> From: Paul Lemmens [mailto:P.Lemmens at nici.kun.nl]
> Sent: 14 October 2003 16:10
> To: r-help at stat.math.ethz.ch
> Subject: RE: is.na(v)<-b (was: Re: [R] Beginner's query - segmentation
> fault)
> 
> 
> Security Warning:
> If you are not sure an attachment is safe to open please contact 
> Andy on x234. There are 0 attachments with this message.
> ________________________________________________________________
> 
> 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
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
 

Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 644449
Fax: +44 (0) 1379 644445
email: Simon.Fear at synequanon.com
web: http://www.synequanon.com
 
Number of attachments included with this message: 0
 
This message (and any associated files) is confidential and\...{{dropped}}




More information about the R-help mailing list