R FAQ 7.31 strikes again. :-)
Michael tmp[3105] == 35.52 [1] FALSE tmp[3105] - 35.52 [1] -7.105427e-15 all.equal(tmp[3105], 35.52) TRUE On Wed, Nov 16, 2011 at 10:42 AM, oscar <ob...@cam.ac.uk> wrote: > Hello. > > I recently came across the extremely strange problem (see below) of R > telling me that elements of a list do not exist... > > I have tried running this small script on 2 computers (Mac OSX 10.7 & > Windows 7) running the latest releases or R (2.13.2 on Mac, 2.14.0 on Win). > I have tried it both in the standard R console, and in RStudio (v. > 0.94.110), and all have the same problem. > > Any ideas?! I'm stumped... > > Thanks, > > Oscar. > > Code (with comments): > > > tmp=seq(20,90,0.005) > > # I want to find the position of 35.52: > which(tmp==35.52) > # integer(0) -- It's not there?! > > tmp[3100:3110] # check to see if it's there... > # [1] 35.495 35.500 35.505 35.510 35.515 35.520 35.525 35.530 35.535 35.540 > 35.545 -- it is. > which(tmp==35.525) > # [1] 3106 > which(tmp==35.515) > # [1] 3104 > tmp[3105] > # [1] 35.52 > > # Interestingly: > for (i in seq(30.52,50.52,1)) print(paste(i,which(tmp==i))) # works fine... > # ... I'm stuck. > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/R-not-seeing-numbers-tp4076766p4076766.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > ______________________________________________ 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.