[R] Bug check (possibly in seq()). RGui 2.6.2 (2008-02-08)
John Kane
jrkrideau at yahoo.ca
Sun Mar 23 19:25:56 CET 2008
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.
>
More information about the R-help
mailing list