[R] na.omit

Kjetil Kjernsmo kjetil.kjernsmo at astro.uio.no
Tue Jul 18 15:29:06 CEST 2000


On Mon, 17 Jul 2000, Prof Brian D Ripley wrote:

>> Error in 1:numeric(0) : NA/NaN argument
>> In some cases, it has seemed to me that it would have been sooo much more
>> convenient if it returned
>> numeric(0)
>
>Why is that a sensible answer? 

Well, I didn't say sensible, I said convenient.... :-) I don't know if it
is sensible (yet), but the reason it I have found it could be convenient 
is if I had a vector x, and I wanted elements 1:n, and n in some special
case happened to be unspecified, x[1:n] would also not be specified.

> 1:x expects a length-one vector x,
>preferably an integer one.  And 1:0, for example, is not a length-zero
>vector.  If x is not specified, 1:x is also not specified.  In particular,
>its length is not specified (and hence not specified as zero) and so
>a vector of NAs will not do.

Indeed. In the above case, I would have to compute n, check if is
unspecified, if it is, return numeric(0), if not return the result. If
1:numeric(0) was, well, integer(0), I wouldn't have to worry about those
checks.

>If you really, really wanted this it should be integer(0) for consistency.
>(1:n has storage mode integer.)

Fine with me! 

>S does try to do sensible things in boundary cases (in the Unix tradition),
>but only where (almost) everyone can agree on what is sensible.

Yes, and it does a good job!

Best,

Kjetil
-- 
Kjetil Kjernsmo
Graduate astronomy-student                    Problems worthy of attack
University of Oslo, Norway            Prove their worth by hitting back
E-mail: kjetikj at astro.uio.no                                - Piet Hein
Homepage <URL:http://www.astro.uio.no/~kjetikj/>
Webmaster at skepsis.no 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list