I am importing an excel file into R, however, some of the values are changing from the original value by adding a significant number of decimal places.
i.e The original value may be 77.21 but is changed to 72.209999999999994. I figure it has something to do with floating point numbers?
I know this example would round back to 72.21, however, sometimes it is occurring on much smaller numbers.
I also need to ensure the reported value in the excel sheet is what is getting imported.
Does anyone have ideas how to manage this?
Here is a sample of how the data is stored in excel
- sample Ni Co Al2O3 Fe2O3 S etc....
- 84564 <0.005 <0.005 2.65 77.21 0.052
- 84107 <0.005 <0.005 2.64 77.18 0.051
....
the "<" less than indicated below detection and is handled else where.
my code is : data <- read_excel(file.path)
what I get in R is
- sample Ni Co Al2O3 Fe2O3 S
- 84564 <0.005 <0.005 2.6499999999999999 77.209999999999994 0.051999999999999998
- 84107 <0.005 <0.005 2.6400000000000001 77.180000000000007 0.050999999999999997
Some fields need to be round 2 decimals places and some 3 or 4. My main concern is that numbers may get rounded or modified beyond the detection limit.