> Why are the first two yielding an integer after multiplying, and the last two
> don't?
> Apparently, c(0.8,0.6,0.4,0.2) can't be represented exactly.
Most fractions cannot be represented exactly. Also, you cannot depend
on the third element of seq(.2,.8,by=.2) being equal to .6 (it is
slightly
Thank you.
I got the point with non-integer values in rep(). I also red FAQ 7.3:
"The only numbers that can be represented exactly in R’s numeric type
are integers and fractions whose denominator is a power of 2."
But then I still don't understand:
> for (b in seq(0.2,0.8,0.2))
+ {
+ a <- (1
On 15/09/2014 16:30, Samuel Knapp wrote:
Dear all,
I have discovered a bug in the standard rep() function: At certain
Not so:
> a <- (1-0.9)*100
> trunc(a)
[1] 9
As the help says
Non-integer values of ‘times’ will be truncated towards zero. If
‘times’ is a computed quantity it is
No, actually you've discovered FAQ 7.31.
> a <- (1-0.9)*100
> a
[1] 10
> print(a, digits=20)
[1] 9.9982236
In combination with the description in ?rep:
Non-integer values of ‘times’ will be truncated towards zero. If
‘times’ is a computed quantity it is prudent to add a sma
Dear all,
I have discovered a bug in the standard rep() function: At certain
values, rep() does not replicate the element by the proper number of times:
> a <- (1-0.9)*100
> a
[1] 10
> length(rep(1,times=a))
[1] 9
> length(rep(1,each=a))
[1] 9
As shown, this happens as well for the times= as
5 matches
Mail list logo