An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100113/23abeac0/attachment.pl>
<= returns wrong result? Why
5 messages · Trafim Vanishek, Liviu Andronic, Peter Ehlers +2 more
On 1/13/10, Trafim Vanishek <rdapamoga at gmail.com> wrote:
this is the output result
> Rk[47] <= RB[21]
[1] FALSE
> Rk[47]
[1] 0.002842007
> RB[21]
[1] 0.002842007
I would suspect that, if you're looking at all the digits, the two are not exactly the same. I would try round(Rk[47], 10) <= round(RB[21], 10) Liviu
Trafim Vanishek wrote:
Dear all, Does anybody know the probable reason why <= gives false when it should give true? These two variables are of the same type, and everything works in the cycle but then it stops when they are equal. this is the output result
Rk[47] <= RB[21]
[1] FALSE
Rk[47]
[1] 0.002842007
RB[21]
[1] 0.002842007 Thanks a lot.
What makes you think that Rk[47] and RB[21] are equal? You're only showing 9-decimal print versions. -Peter Ehlers
[[alternative HTML version deleted]]
______________________________________________ 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.
Peter Ehlers University of Calgary 403.202.3921
Hi Trafim, take a look at FAQ 7.31. HTH Stephan Trafim Vanishek schrieb:
Dear all, Does anybody know the probable reason why <= gives false when it should give true? These two variables are of the same type, and everything works in the cycle but then it stops when they are equal. this is the output result
Rk[47] <= RB[21]
[1] FALSE
Rk[47]
[1] 0.002842007
RB[21]
[1] 0.002842007 Thanks a lot. [[alternative HTML version deleted]]
______________________________________________ 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.
Yupp, FAQ 7.31 is definitely your friend here. You might also want to take a look at these two very recent threads on this help list: "Strange behaviour of as.integer()" http://tolstoy.newcastle.edu.au/R/e9/help/10/01/index.html#547 "Newbie question on precision" http://tolstoy.newcastle.edu.au/R/e9/help/10/01/index.html#718 Best, Magnus
On 1/13/2010 3:25 AM, Stephan Kolassa wrote:
take a look at FAQ 7.31. Trafim Vanishek wrote:
Does anybody know the probable reason why <= gives false when it should give true?