[R] choose() function returning anomalous results (zero instead of one)
David Winsemius
dwinsemius at comcast.net
Fri Sep 7 00:00:59 CEST 2012
On Sep 6, 2012, at 2:45 PM, Shayne Hodge wrote:
> I accidentally posted the wrong version of my code, omitting the Q1 loop,
> and, sure enough that loop generates non-integers:
>
> qfracseq <- seq(from = 1, to = 0, by = -.1)
> Q <- 10
> Qseq <- Q*qfracseq
>
>> Qseq [1] 10.00000000000000000 9.00000000000000000 8.00000000000000000 7.00000000000000000
> [5] 6.00000000000000000 5.00000000000000000 3.99999999999999911
> 2.99999999999999911
> [9] 1.99999999999999956 0.99999999999999978 0.00000000000000000
>
>
> -----
>
> I'm a tad puzzled by why my code would do this; is this a result of some
> base-10 fractions not representing as cleanly in base-2 as in -10?
Read the FAQ. ("Why doesn't R think these numbers are equal?") Can't remember for sure but suspect someplace around 7.31
snipped
--
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list