Skip to content

beginner help: 10th index is being overwritten by 11th

3 messages · Loyack, Eric, Berend Hasselman, Duncan Murdoch

#
On 30-11-2013, at 08:37, Loyack, Eric <eloyack at arcadia.edu> wrote:

            
R FAQ 7.31 (http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f)

Insert print(formatC(10*rho+1,digits=16,format="f")) before the line with print(PTMpvalMeans[rho*10 + 1]) in your code and you should see what?s wrong.

Use an explicit counter variable k and increment with k <- k+1 to index your vectors.

Berend
#
On 13-11-30 4:37 PM, Loyack, Eric wrote:
It looks like a fairly obscure case of FAQ 7.31.  It's a bad idea to use 
0.1 as a loop increment, because fractions like that can't be 
represented exactly, and rounding error accumulates.

Duncan Murdoch