[R] Rounding like in finances

2010-02-22 Thread Oliver
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@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.


Re: [R] Rounding like in finances

2010-02-22 Thread Henrique Dallazuanna
 round(245.455, 2) ?

On Mon, Feb 22, 2010 at 11:06 AM, Oliver oli...@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@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

__
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.


Re: [R] Rounding like in finances

2010-02-22 Thread Oliver
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@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.


Re: [R] Rounding like in finances

2010-02-22 Thread Duncan Murdoch

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

__
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.


Re: [R] Rounding like in finances

2010-02-22 Thread Ivan Calandra

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@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.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

__
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.


Re: [R] Rounding like in finances

2010-02-22 Thread Oliver
Hello,


which packages are you talking about?

And... are thoise packages using integer-based calculations?

__
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.


Re: [R] Rounding like in finances

2010-02-22 Thread Duncan Murdoch

On 22/02/2010 9:57 AM, Oliver wrote:

Hello,


which packages are you talking about?

And... are thoise packages using integer-based calculations?

I don't use this, but the ones I'd look in would be:

MASS (function rational())
rcdd
Rmpfr

You can use

RSiteSearch(rational)

to look for more.

Duncan Murdoch

__
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.


Re: [R] Rounding like in finances

2010-02-22 Thread Oliver

Duncan Murdoch murdoch at stats.uwo.ca writes:
[...]
 MASS (function rational())
 rcdd
 Rmpfr
[...]



OK, I will look for those packages.
Maybe they will help.

Thank you.

__
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.