[R] R not 'seeing' numbers?!
oscar
ob266 at cam.ac.uk
Wed Nov 16 16:42:36 CET 2011
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.
More information about the R-help
mailing list