[Rd] Re: [R] na.omit (PR#610)
bates@stat.wisc.edu
bates@stat.wisc.edu
Mon, 17 Jul 2000 22:11:30 +0200 (MET DST)
buerkle@hawaii.edu writes:
> Why is it that when a vector contains no NAs, na.omit returns an empty
> vector rather than the object/vector that was passed to it?
>
> >na.omit(c(1,2,3,4))
> numeric(0)
Well, because there is a bug in na.omit.default. The problem is in the
section of code
omit <- seq(along = object)[is.na(object)]
nm <- names(object)
object <- object[-omit]
If there are no NA's in the object, then omit becomes a length 0
vector and -omit doesn't have the intended effect.
A temporary fix would be to insert
if (length(omit) == 0) return(object)
after the first line shown above.
We'll incorporate a fix for the next release. Thanks for reporting
the bug.
> ---------------------------
> platform i686-pc-linux-gnu
> arch i686
> os linux-gnu
> system i686, linux-gnu
> status
> major 1
> minor 1.0
> year 2000
> month June
> day 15
> language R
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
Douglas Bates bates@stat.wisc.edu
Statistics Department 608/262-2598
University of Wisconsin - Madison http://www.stat.wisc.edu/~bates/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._