SET Eric Brendan
2008-Mar-23 17:48 UTC
[R] Bug check (possibly in seq()). RGui 2.6.2 (2008-02-08)
Hello All, I'm new to R, but I can't account for the results from the simple script below and it looks simple enough. Description: When A is generated by seq(), A[A==x] incorrectly returns numeric(0) for some values of x (in A) but not others. ########################## A<-seq(0,1,by=.05) #These return numeric(0), but others in the set return the correct value A[A==.3] A[A==.6] A[A==.7] A[A==.15] A[A==.35] A[A==.85] A[A==.95] #A[20] # This works fine B<-seq(0,1,by=.05) A[A==B] # This also works fine A<-c(0,.05,.1,.15,.2,.25,.30,.35,.40,.45, .50,.55,.6,.65,.7,.75,.8,.85,.9,.95,1) A[A==.3] ########################## R, RGui 2.6.2 (2008-02-08) Windows XP Professional SP 2 Pentium(R) D CPU 2.80GHz, 2G RAM Hoping someone else can reproduce it. Regards, Eric Set
John Kane
2008-Mar-23 18:25 UTC
[R] Bug check (possibly in seq()). RGui 2.6.2 (2008-02-08)
See the R-FAQ 7.31 Why doesn't R think these numbers are equal? for the likely reason. --- SET Eric Brendan <ericset at ust.hk> wrote:> Hello All, > > I'm new to R, but I can't account for the results > from the simple script > below and it looks simple enough. > > Description: When A is generated by seq(), A[A==x] > incorrectly returns > numeric(0) for some values of x (in A) but not > others. > > ########################## > A<-seq(0,1,by=.05) > > #These return numeric(0), but others in the set > return the correct value > A[A==.3] > A[A==.6] > A[A==.7] > A[A==.15] > A[A==.35] > A[A==.85] > A[A==.95] #A[20] > > # This works fine > B<-seq(0,1,by=.05) > A[A==B] > > # This also works fine > A<-c(0,.05,.1,.15,.2,.25,.30,.35,.40,.45, > .50,.55,.6,.65,.7,.75,.8,.85,.9,.95,1) > A[A==.3] > ########################## > > R, RGui 2.6.2 (2008-02-08) > Windows XP Professional SP 2 > Pentium(R) D CPU 2.80GHz, 2G RAM > > Hoping someone else can reproduce it. > > Regards, > Eric Set > > ______________________________________________ > 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. >
Seemingly Similar Threads
- Creating a graphics window (in Windows, with RGui) that is not constrained to the RGui Window
- A bug (?) in Rgui Configuration Editor (buffer lines) in R1.2.0 for Windows (Rgui.exe)
- Bug in "seq" (or a "feature") ?
- RGui innards questions
- Rgui never processes ~/.Renviron