From p.dalgaard at biostat.ku.dk  Wed Sep 30 20:56:19 2009
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Wed, 30 Sep 2009 20:56:19 +0200
Subject: [Rd] buglet in is.na?
In-Reply-To: <1254335346.8321.1337412857@webmail.messagingengine.com>
References: <1254335346.8321.1337412857@webmail.messagingengine.com>
Message-ID: <4AC3A9D3.2010607@biostat.ku.dk>

Nicholas Lewin-Koh wrote:
> Hi
> the following example I think demonstrates the inconsistency
>> f<-function(x) x
>> length(f)
> [1] 1
>> is.na(f)
> [1] FALSE
> Warning message:
> In is.na(f) : is.na() applied to non-(list or vector) of type 'closure'
> 
> The documentation states:
> Arguments
> x       an R object to be tested.
> value   a suitable index vector for use with x.
> 
> And nowhere in the details was it implied (to me anyway) that x could
> not be a function
> or anything else in R for that matter. Did I miss something?
> 

Well, it's just a warning which you get whenever you apply is.na to 
things that cannot logically be NA, e.g.

 > is.na(.GlobalEnv)
[1] FALSE FALSE
Warning message:
In is.na(.GlobalEnv) :
   is.na() applied to non-(list or vector) of type 'environment'
 > is.na(quote(a))
[1] FALSE
Warning message:
In is.na(quote(a)) :
   is.na() applied to non-(list or vector) of type 'symbol'
 > is.na(quote(`NA`))
[1] FALSE
Warning message:
In is.na(quote(`NA`)) :
   is.na() applied to non-(list or vector) of type 'symbol'
 > is.na(is.na)
[1] FALSE
Warning message:
In is.na(is.na) : is.na() applied to non-(list or vector) of type 'builtin'

I suppose the documentation could be more explicit about it, but where's 
the need?

-- 
    O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



[Rd] buglet in is.na?
Peter Dalgaard