From p.dalgaard at biostat.ku.dk  Fri Apr  4 22:09:32 2003
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard BSA)
Date: Fri Apr  4 21:09:40 2003
Subject: [Rd] Bug in %in% (match)
In-Reply-To: <1049447236.11249.7.camel@sta49.stat.nus.edu.sg>
References: <1049447236.11249.7.camel@sta49.stat.nus.edu.sg>
Message-ID: <x2pto2w043.fsf@biostat.ku.dk>

Nicholas Lewin-Koh <nikko@hailmail.net> writes:

> Hi,
> Am I hitting some limit in match? Consider the following example:
> 
> > tst<-seq(100,125,by=.2)%in%seq(0,800,by=.1)
> > sum(tst)
> [1] 76

> Gives the correct answer. Did I miss something?

The fact that 1/5 and 1/10 are not represented exactly in a binary
computer? 

> sum(tst<-seq(100,125,by=.2)%in%seq(0,800,by=.1))
[1] 76
> sum(tst<-seq(100,125,by=.2)%in%round(seq(0,800,by=.1),1))
[1] 126

And, just to be sure:

> sum(round(seq(100,125,by=.2),1)%in%round(seq(0,800,by=.1),1))
[1] 126


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] Bug in %in% (match)
Peter Dalgaard BSA