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.
Hi, you probably want to use ?all.equal instead of "==" I couldn't run your example, though Hope this helps, baptiste On 27 Feb 2009, at 10:32, Peterko wrote:> > 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. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code._____________________________ Baptiste Augui? School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag
Hi all, According to the help page on round(), round(1.5) could be either 1 or 2. But I want to the answere to be 2 for sure just what we usually do. How can I do that? Thanks advance. Cheers Ted -- View this message in context: http://www.nabble.com/rounding-problem-tp22261852p22261852.html Sent from the R help mailing list archive at Nabble.com.
it the on-line help file of ?round, you can also find the functions: ceiling() floor() trunc() I hope it helps. Best, Dimitris tedzzx wrote:> Hi all, > > According to the help page on round(), round(1.5) could be either 1 or 2. > But I want to the answere to be 2 for sure just what we usually do. How can > I do that? Thanks advance. > > Cheers > > Ted-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014