From kellymj1 at cf.ac.uk  Wed Aug 30 13:25:45 2006
From: kellymj1 at cf.ac.uk (kellymj1 at cf.ac.uk)
Date: Wed, 30 Aug 2006 13:25:45 +0200 (CEST)
Subject: [Rd] Inaccuracy in seq() (PR#9189)
Message-ID: <20060830112545.EC5042245F@slim.kubism.ku.dk>

Full_Name: Mark James Kelly
Version: 2.3.1
OS: Windows
Submission from: (NULL) (193.63.127.224)


Sequence produces slightly inaccurate results. 

#This (supposedely) creates a sequence 0.060,0.065,0.070.....0.30
thingnor=(seq(0.06,0.30,by=0.005))

#This does the same but rounds to three decimals
thingrou=round(seq(0.06,0.30,by=0.005),3)

#This is another vector, the same length as the two above, with 24 zeroes, then
0.070, then 24 zeroes
otherthing=c(rep(0,24),0.070,rep(0,24))


#This fails to select the entries equal to 0.070 
otherthing[otherthing==thingnor[3]]

#This gives the correct answer
otherthing[otherthing==thingrou[3]]


#This compares the two sequences (which should be identical)
(thingnor-thingrou)




[Rd] Inaccuracy in seq() (PR#9189)
kellymj1 at cf.ac.uk