> -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Heemun Kwok > Sent: Tuesday, July 26, 2011 8:50 PM > To: r-help@r-project.org > Subject: [R] "match" and "which" give NA for some values, but not others > > Hello list, > I am having trouble with "match" and "which" giving a NA result for some > values, but not others. Here is a simple example: > > > aaa <- seq(0,1,by=0.05) > > > aaa > [1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 > 0.70 > [16] 0.75 0.80 0.85 0.90 0.95 1.00 > > > match(0.5,aaa) > [1] 11 > > > match(0.6,aaa) > [1] NA > > > which(aaa==0.5) > [1] 11 > > > which(aaa==0.6) > integer(0) > > > sessionInfo() > R version 2.12.2 (2011-02-25) > Platform: i386-pc-mingw32/i386 (32-bit) > > Am I missing something? Any thoughts? > > Thank you, > Heemun > >
Take a look at R FAQ 7.31. Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA ______________________________________________ R-help@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.