[R] Bug or just a problem with the computer precision?
jholtman at gmail.com
Thu Oct 4 15:06:37 CEST 2007
You are getting round-off problems (I think it is FAQ 7.33). Use
characters since thats what the numbers really are. Convert the
characters and then use substring. Also sprintf works:
> sprintf("%.2f", A*100)
> sprintf("%.2f", A)
On 10/4/07, Renger van Nieuwkoop <renger at ecoplan.ch> wrote:
> I have the following problem: I have a lot of numbers that identify
> import goods according to the Harmonised System (8 numbers in two groups
> with a dot in between). I want to move to the
> 6 numbers (4 numbers, dot, two numbers). My trick to do this works for
> all the numbers in the Harmonised Sytem but not for this one:
> (A<-floor(100 * A ) / 100) = 4709.89
> But this has to be 4709.90
> If I do this in Excel it works fine...Any idea how to make sure that I
> get 4709.90 and not 4709.89?
> Forschung und Beratung in Wirtschaft und Politik
> Economic Research and Policy Consultancy
> Thunstrasse 22 / CH-3005 Berne (Switzerland)
> Phone: +41 31 356 61 61 / Fax: +41 31 356 61 60
> mailto:renger at ecoplan.ch / http://www.ecoplan.ch>
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help