[R] Help with which()

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Jul 24 18:33:33 CEST 2008


On 24-Jul-08 15:35:45, Erik Iverson wrote:
> See
> 
> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-the
> se-numbers-are-equal_003f

That's not an applicable response: The difference between 3573.1
and 3573.15 is far too large for them to be confused by "==".
Thr confusion only sets in at a difference of around 1e-15.
In any case, test it for yourself:

  3573.1==3573.15
# [1] FALSE

The only explanations I can think of are on the lines of
a) Nina thinks that the second position holds 3573.15, but it
   really holds 3573.1 and Nina was mistaken about the position.

b) For some reason, a number in Operons which has been entered
   as, and reads on screen as, 3573.15 is being read as 3573.1
   by R. I have no idea how that could happen, but it might be
   possible if a stray byte (not visible on screen) has crept
   in between the "1" and the "5": 3573.1?5

I think the first thing is that Nina should check the contents
of Operons very carefully.

What is the result of

  Operons[which(Operons==3573.1,arr.ind=TRUE)]

??

Ted.
> naw3 at duke.edu wrote:
>> Hi,
>> 
>> I'm using which to find the position of a value in my data table,
>> and it is returning the correct position and the position of
>> another number that differs by an extra decimal place. For example,
>> when I do:
>> 
>> where1<-which(Operons==3573.1,arr.ind=TRUE)
>> 
>> it returns the position of that number and of 3573.15.
>> 
>> Is it possible to get the function to only return a position if
>> the number matches exactly?
>> 
>> Thanks,
>> -Nina
>> 
>> ______________________________________________
>> 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.
> 
> ______________________________________________
> 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.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 24-Jul-08                                       Time: 17:33:26
------------------------------ XFMail ------------------------------



More information about the R-help mailing list