[R] na.omit leaves cases with NA's intact

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Oct 31 21:18:23 CET 2009


What class is 'orginaldata' (and its columns if a data frame)?
Note that packge xts defines methods for na.omit:

> library(xts)
...
> methods(na.omit)
[1] na.omit.data.frame* na.omit.default*    na.omit.ts*
[4] na.omit.xts*

so this is possibly something peculiar to package xts.  See the footer 
of this message: a reproducible example would help enormously in 
finding the root cause here.

On Sat, 31 Oct 2009, David L. Van Brunt, Ph.D. wrote:

> Strange, this normally works, but in a recent run, I have a data set in an
> xts format, that has a lot of NA's in a few of the variables in the leading
> and trailing positions, due to some lagging calculations. Before running an
> analysis, I use
>
> newdata<-na.omit(orginaldata)
>
> and normally a
>
> dim(newdata)
>
> shows the fewer rows. Now, for some reason I do this operation and see that
> hundreds of rows SHOULD be removed, (I can plainly see the NAs in there) and
> even test is.na(orginaldata$variable) and get a clear "TRUE", but the case
> still remains after the "na.omit" operation. Yes, I'm spelling it right.
>
> I'm doing this with many sets of data, and it works great except for this
> one data set....
>
> Any idea if there are limits on when this function works, or more
> importantly, if there is a "manual" way to do it as a workaround?
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list