Thank for your help, and sorry for posting before reading the FAQ, I know it is one of the basic rules. Though, knowing myself I would never relate the error in rep with 0.29*100!=29
2013/4/9 arun <smartpink...@yahoo.com> > Possibly R FAQ 7.31 > > length(rep(TRUE,signif(0.29*100,2))) > #[1] 29 > A.K. > > > ----- Original Message ----- > From: Jorge Fernando Saraiva de Menezes <jorgefernandosara...@gmail.com> > To: r-help@r-project.org > Cc: > Sent: Tuesday, April 9, 2013 12:11 PM > Subject: [R] rep() fails at times=0.29*100 > > Dear list, > > I have found an unusual behavior and would like to check if it is a > possible bug, and if updating R would fix it. I am not sure if should post > it in this mail list but I don't where is R bug tracker. The only mention I > found that might relate to this is "If times is a computed quantity it is > prudent to add a small fuzz." in rep() help, but not sure if it is related > to this particular problem > > Here it goes: > > > rep(TRUE,29) > [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE > TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE > [28] TRUE TRUE > > rep(TRUE,0.29*100) > [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE > TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE > [28] TRUE > > length(rep(TRUE,29)) > [1] 29 > > length(rep(TRUE,0.29*100)) > [1] 28 > > Just to make sure: > > 0.29*100 > [1] 29 > > This behavior seems to be independent of what is being repeated (rep()'s > first argument) > > length(rep(1,0.29*100)) > [1] 28 > > Also it occurs only with the 0.29. > > length(rep(1,0.291*100)) > [1] 29 > > for(a in seq(0,1,0.01)) {print(sum(rep(TRUE,a*100)))} #also shows correct > values in values from 0 to 1 except for 0.29. > > I have confirmed that this behavior happens in more than one machine > (though I only have session info of this one) > > > > sessionInfo() > R version 2.15.3 (2013-03-01) > Platform: x86_64-w64-mingw32/x64 (64-bit) > > locale: > [1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 > LC_MONETARY=Portuguese_Brazil.1252 > [4] LC_NUMERIC=C LC_TIME=Portuguese_Brazil.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] spatstat_1.31-1 deldir_0.0-21 mgcv_1.7-22 > > loaded via a namespace (and not attached): > [1] grid_2.15.3 lattice_0.20-13 Matrix_1.0-11 nlme_3.1-108 > tools_2.15.3 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > > [[alternative HTML version deleted]] ______________________________________________ R-help@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.