Re: [R] na.omit - Is it working properly?

From: P Ehlers <ehlers_at_ucalgary.ca>
Date: Tue, 03 May 2011 20:06:03 -0600

Kalicin, Sarah wrote:
\begin{quote}
I have a work around for this, but can someone explain why the first example does not work properly? I believed it worked in the previous version of R, by selecting just the rows=200525 and omitting the na's. \end{quote}

You can prove this statement by providing reproducible code that we can test.

Peter Ehlers

I just upgraded to 2.13. I am also concern with the row numbers being different in the selections, should I be worried? FYI, I just selected the first few rows for demonstration, please do not worry that the number of rows shown are not equal. - Sarah
>
> With na.omit around the column, but it is showing other values in the F.WW column other than 200525, along with NA. I was hoping that this would omit all the NA's, and show all the rows that P$F.WW=200525. I believe it did with the previous version of R. > P[na.omit(P$F.WW)==200525, c(51, 52)]
> F.WW R.WW
> 45 200525 NA
> 53 NA NA
> 61 200534 200534
> 63 200608 200608
> 66 200522 200541
> 80 NA NA
> 150 200521 200516
> 231 200530 200530
>
> No na.omit, the F.WW=200525 seems to work, but lots of NA included. This is what is expected!! The row numbers are not the same as the above example, except the first row.

>> P[P$F.WW==200525, c(51, 52)] > F.WW R.WW > 45 200525 NA > NA NA NA > NA.1 NA NA > NA.2 NA NA > NA.3 NA NA > 57 200525 200526 > 65 200525 NA > 67 200525 NA > 70 200525 200525 > NA.4 NA NA > NA.5 NA NA > 86 200525 NA  > > Na.omit excludes the na's. This is what I want. The concern I have is why the row numbers do not match any of those shown in the examples above. >> na.omit(P[P$F.WW==200525, c(51, 52)])

>         F.WW        R.WW
> 57    200525      200526

> 70    200525      200525
> 161   200525      200525
> 245   200525      200525
> 246   200525      200525
> 247   200525      200526
> 256   200525      200525
> 266   200525      200525
> 269   200525      200525
> 271   200525      200526
> 276   200525      200526
> 278   200525      200526
>
> 	[[alternative HTML version deleted]]

>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help