[R] How to menage decimals in order to obtain accurate estimates

S Ellison S.Ellison at LGCGroup.com
Wed Feb 6 12:15:02 CET 2013


 
> I've checked my iteration loop with other dataset, i've not 
> problems with integer numbers or other dataset with decimals 
> but not all decimals dataset.
Any R data set that is 'not all decimals' will be represented internally as floating point* (eg c(1, 2, 3, 1.5) consists of four floating point numbers, not three integers and a float), and floating point operations on integer data will cause conversion to floating point as well. That makes it likely that _all_ the operations you are doing treat the data as decimal, whether you can see digits after the decimal point or not.

And R does not round by default until it prints, with the exception of the natural truncation of double precision floating point numbers at around 16 digits (see FAQ 7.31). 

That implies to me that your problem is not in the decimal/integer question; rather, you have a problem (or unanticipated feature) in your code that is visible on some floating point data sets but not others and it happens that the problem data set contains visibly non-integer data.

So you're probably going to have to provide a reproducible example before anyone can help further. 


*Unless it's a list or data frame, in which case different elements can be different types. But even then, internal floating point arithmetic will always be in floating point.

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list