Simon Fear
2003-Oct-09 10:26 UTC
is.na(v)<-b (was: Re: [R] Beginner's query - segmentation fault)
> -----Original Message----- > From: Richard A. O'Keefe [mailto:ok at cs.otago.ac.nz]<snip>> The very existence of an "is.na<-" which accepts a logical > vector containing FALSE as well as TRUE ...And don't forget this is not the only usage of is.na<-. In fact it is designed to take any valid indexing value. For example:> a<-1:10 > is.na(a) <- 1:5 > a[1] NA NA NA NA NA 6 7 8 9 10 Wow. I really hate that. Someone tell me again why this is better than a[1:5] <- NA ?? 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}}
Paul Lemmens
2003-Oct-14 15:10 UTC
is.na(v)<-b (was: Re: [R] Beginner's query - segmentation fault)
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
Maybe Matching Threads
- is.na(v)<-b (was: Re: Beginner's query - segmentation fault)
- is.na(v)<-b (was: Re: Beginner's query - segmentation fault)
- is.na(v)<-b (was: Re: Beginner's query - segmentation fault)
- Numbers that look equal, should be equal, but if() doesn't see as equal (repost with code included)
- modulus operator?