Try this:
as.integer(x + sign(x) * .5)
On Sun, May 17, 2009 at 6:01 AM, Thomas Mang wrote:
> Hi,
>
> The problem is, x might be negative. If x == -6.999, the result should
> be -7, not -6. That's why my original proposal had the ifelse-condition (one
> could alternatively write sign(x) * 0.
Hi,
The problem is, x might be negative. If x == -6.999, the result
should be -7, not -6. That's why my original proposal had the
ifelse-condition (one could alternatively write sign(x) * 0.5, BTW.
I agree however that in my proposal, the round(x) is redundant, one can
use x itself as left
Try:
as.integer(x + 0.5)
assuming the calculation error is less than 0.5 .
On Sat, May 16, 2009 at 2:49 PM, Thomas Mang wrote:
> Hello,
>
> Suppose I have x, which is a variable of class numeric. The calculations
> performed to yield x imply that mathematically it should be an integer , but
> d
On Sun, May 17, 2009 at 5:00 PM, Thomas Mang wrote:
> Hi,
>
> Well, also not quite.
> Suppose x = 5.001 (in finite binary represenation). Then I want x ==
> 5, but that is of course an integer which is now less than the original
> numeral.
Sorry for that I haven't got what your mean exactl
How about ceiling(x), which return the smallest integer not less than x?
On Sun, May 17, 2009 at 2:49 AM, Thomas Mang wrote:
> Hello,
>
> Suppose I have x, which is a variable of class numeric. The calculations
> performed to yield x imply that mathematically it should be an integer , but
> due t
Hello,
Suppose I have x, which is a variable of class numeric. The calculations
performed to yield x imply that mathematically it should be an integer ,
but due to round-off errors, it might not be (and so in either
direction). The error is however small, so round(x) will yield the
appropriat
6 matches
Mail list logo