Hello, I need to have a "kaufmaennisches Runden" function. Is there already something like that? It means: rounding up the 5, instead of rounding it down. So, 245.455 would give 245.46 I found no option for this. Maybe there is a package for it? Oliver
round(245.455, 2) ? On Mon, Feb 22, 2010 at 11:06 AM, Oliver <oliver at first.in-berlin.de> wrote:> Hello, > > I need to have a "kaufmaennisches Runden" function. > > Is there already something like that? > > It means: rounding up the 5, instead of rounding it down. > > So, 245.455 would give 245.46 > > I found no option for this. > Maybe there is a package for it? > > > Oliver > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
Oh strange...> round(108.275 , 2)[1] 108.28> round(208.275 , 2)[1] 208.28> round(308.275 , 2)[1] 308.27>looks not like what one should expect... R version 2.9.2 (2009-08-24) Ciao, Oliver
On 22/02/2010 9:06 AM, Oliver wrote:> Hello, > > I need to have a "kaufmaennisches Runden" function. > > Is there already something like that? > > It means: rounding up the 5, instead of rounding it down. > > So, 245.455 would give 245.46 > > I found no option for this. > Maybe there is a package for it?This is a little tricky, because 245.455 is not a representable number in base R. If x is represented as x+epsilon, it will tend to round up, if it is x-epsilon, it will tend to round down. (I say tend to because R tries to do banker's rounding, and the math routines attempt to do exact calculations even when they are not really possible, so it is hard to predict exactly what will happen for a particular number.) There are packages for handling rational numbers that could handle it exactly; I don't know how flexible they are about rounding. Duncan Murdoch
same result with R2.10.1 on Windows... Le 2/22/2010 15:34, Oliver a ?crit :> Oh strange... > > > >> round(108.275 , 2) >> > [1] 108.28 > >> round(208.275 , 2) >> > [1] 208.28 > >> round(308.275 , 2) >> > [1] 308.27 > >> > > looks not like what one should expect... > > > R version 2.9.2 (2009-08-24) > > > > Ciao, > Oliver > > ______________________________________________ > 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. > >-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Institut und Museum Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra at uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php
Apparently Analagous Threads
- replicates in repeated ANOVA
- R/Finance 2009: Applied Finance with R -- Registration now open
- R/Finance 2009: Applied Finance with R -- Registration now open
- R/Finance 2009: Applied Finance with R -- Call for Papers
- R/Finance 2009: Applied Finance with R -- Call for Papers