Re: [R] - round() strange behaviour

2007-08-06 Thread Jim Lemon
(Ted Harding) wrote: ... Thus always up or always down means that the difference between rounded numbers is always the same as between the unrounded numbers which for other methods the differences can differ by 2.0. This may or may not matter, but it is something to think about when choosing

Re: [R] - round() strange behaviour

2007-08-06 Thread John Logsdon
In R you may be tempted to use rounding to index something in an array. Hence my concern and suggestion that there be another argument to round() (and signif()) that explicitly sets the rounding mechanism. In Fortran IDNINT does as I would expect. You could do floor(x+0.5) but many people,

Re: [R] - round() strange behaviour

2007-08-06 Thread Duncan Murdoch
On 06/08/2007 5:46 AM, John Logsdon wrote: In R you may be tempted to use rounding to index something in an array. Hence my concern and suggestion that there be another argument to round() (and signif()) that explicitly sets the rounding mechanism. In Fortran IDNINT does as I would

Re: [R] - round() strange behaviour

2007-08-05 Thread Mark Wardle
I use round() to prepare numbers for display in Sweave documents. While I had appreciated the round to even issue before, I had not given it much thought when automatically writing my output functions/scripts/Sexprs... On 04/08/07, Ted Harding [EMAIL PROTECTED] wrote: On 04-Aug-07 21:57:28, John

Re: [R] - round() strange behaviour

2007-08-04 Thread John Logsdon
that it is normal for R to give a 2 instead of 3. Date: Thu, 2 Aug 2007 22:38:49 +0200 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] - round() strange behaviour On Thu, 2 Aug 2007, Monica Pisica wrote: Hi, I am getting some strange results using round

Re: [R] - round() strange behaviour

2007-08-04 Thread Ted Harding
On 04-Aug-07 21:57:28, John Logsdon wrote: I must admit I had never realised this so thanks to Monica for raising it. Round-to-even is used for statistical reasons and there is some point as it obviously reduces bias. But why should the decision be to round to the nearest even number?

[R] - round() strange behaviour

2007-08-02 Thread Monica Pisica
Hi, I am getting some strange results using round - it seems that it depends if the number before the decimal point is odd or even For example: round(1.5)[1] 2 round(2.5)[1] 2 While i would expect that round(2.5) be 3 and not 2. Do you have any explanation for that? I really

Re: [R] - round() strange behaviour

2007-08-02 Thread Peter Dalgaard
Monica Pisica wrote: Hi, I am getting some strange results using round - it seems that it depends if the number before the decimal point is odd or even For example: round(1.5)[1] 2 round(2.5)[1] 2 While i would expect that round(2.5) be 3 and not 2. Do you have

Re: [R] - round() strange behaviour

2007-08-02 Thread Thomas Lumley
On Thu, 2 Aug 2007, Monica Pisica wrote: Hi, I am getting some strange results using round - it seems that it depends if the number before the decimal point is odd or even Yes. This is explained in the help page for round(). -thomas Thomas Lumley Assoc.

Re: [R] - round() strange behaviour

2007-08-02 Thread JRG
On 2 Aug 2007 at 20:16, Monica Pisica wrote: Hi, I am getting some strange results using round - it seems that it depends if the number before the decimal point is odd or even For example: round(1.5)[1] 2 round(2.5)[1] 2 While i would expect that round(2.5) be 3 and not 2.

Re: [R] - round() strange behaviour

2007-08-02 Thread Monica Pisica
didn't realize that it is normal for R to give a 2 instead of 3. Date: Thu, 2 Aug 2007 22:38:49 +0200 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] - round() strange behaviour On Thu, 2 Aug 2007, Monica Pisica wrote:Hi, I am getting some strange

Re: [R] - round() strange behaviour

2007-08-02 Thread Achim Zeileis
On Thu, 2 Aug 2007, Monica Pisica wrote: Hi, I am getting some strange results using round - it seems that it depends if the number before the decimal point is odd or even For example: round(1.5)[1] 2 round(2.5)[1] 2 While i would expect that round(2.5) be 3 and not 2. Do you

Re: [R] - round() strange behaviour

2007-08-02 Thread David C. Howell
That is what it is supposed to do. From ?round we get Note that for rounding off a 5, the IEC 60559 standard is expected to be used, “go to the even digit”. Therefore round(0.5) is 0 and round(-1.5) is -2. However, this is dependent on OS services and on representation error (since e.g. 0.15