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

From: Andrew Robinson <A.Robinson_at_ms.unimelb.edu.au>
Date: Wed, 04 May 2011 09:30:25 +1000

Hi Sarah,

I'm not sure that I understand your problem. You have shown us three ways to try to omit missing values, and one of them seems to work. But you're concerned because some aspect of it doesn't match the ones that don't work? But they don't work!

I wonder if you could send an example in commented, minimal, self-contained, reproducible code ...

Cheers

Andrew

On Tue, May 03, 2011 at 12:18:03PM -0700, Kalicin, Sarah wrote:
>
> 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. 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
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Andrew Robinson  
Program Manager, ACERA 
Department of Mathematics and Statistics            Tel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia               (prefer email)
http://www.ms.unimelb.edu.au/~andrewpr              Fax: +61-3-8344-4599
http://www.acera.unimelb.edu.au/

Forest Analytics with R (Springer, 2011) 
http://www.ms.unimelb.edu.au/FAwR/
Introduction to Scientific Programming and Simulation using R (CRC, 2009): 
http://www.ms.unimelb.edu.au/spuRs/

______________________________________________
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.
Received on Thu 05 May 2011 - 06:25:11 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 07:00:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive