Re: R-alpha: Three bugs + two fixes

Peter Dalgaard BSA (p.dalgaard@kubism.ku.dk)
26 Feb 1997 11:23:34 +0100


To: r-testers@stat.math.ethz.ch
Subject: Re: R-alpha: Three bugs + two fixes
From: Peter Dalgaard BSA <p.dalgaard@kubism.ku.dk>
Date: 26 Feb 1997 11:23:34 +0100
In-Reply-To: Martyn Plummer's message of Wed, 26 Feb 1997 09:25:11 +0100 (MET)
Message-Id: <x2ybcblvbt.fsf@bush.kubism.ku.dk>

Martyn Plummer <plummer@iarc.fr> writes:

> 3) is.na() treats data frames as lists. It always returns a vector of FALSE
> values with the same length as the names attribute.

My initial reaction to this was: "but they *are* lists". One tends to
think of them as "data matrices", but much of the useful syntax really is
list-like, and in fact

> is.list(dfr)
[1] TRUE
but
> is.matrix(dfr)
[1] FALSE

However, that NA is not an element of the list of vectors in a data
frame is hardly informative, so it is reasonable to expect different
behaviour.

Splus has 

is.na(dfr)
  x y 
1 F F
2 F F
3 F F

> class(dfr)<-""
> is.na(dfr)
[1] F F
attr(, "row.names"):
[1] "1" "2" "3"
attr(, "class"):
[1] ""

So the logic seems to be to special-case data frames by having is.na
look for the "data.frame" class and if so, recurse into the component
vectors. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-