[R] rounding problem

Peterko lanikpeter at gmail.com
Fri Feb 27 11:32:05 CET 2009


hi i am creating some variables from same data, but somewhere is different
rouding.
look:
 P = abs(fft(d.zlato)/480)^2 
 hladane= sort(P,decreasing=T)[1:10]/480 
  
 pozicia=c(0,0,0,0,0) 
 for (j in 1:5){ for (i in 2:239){
  if (P[i]/480==hladane[2*j-1]){pozicia[j]=i-1}}}
 period=479/pozicia  

> P[2]/334 
 [1] 0.0001279107 
 > hladane[1]
 [1] 0.0001279107
 > P[2]/334==hladane[1]
 [1] FALSE
> abs(P[2]/334 - hladane[1]) < 0.0000001
 [1] TRUE

It is possible to avoid it ?
I know in this exam i can use 2x if to eliminate this rouding, but i need to
fix it in general.
-- 
View this message in context: http://www.nabble.com/rounding-problem-tp22243179p22243179.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list