0

I have upgraded the latest version of R 6.3.1. I have tried to import a large .csv file which contains both numeric and string data. I have noticed that the numeric data does not seem to import correctly. The decimal places in R do not appear to be correct. For example: Outstanding Balance Column.

If I sum this column in Excel I get the following result 167050951793.0550000

When I sum the same Column in R I get the following result 167050951792.9998

I have Excel 365. I saved the Excel file as .csv. Before doing so I converted all the number fields to numeric format with 2 decimal places

  1. I have prepared the data in Excel.
  2. Before saving the file as CSV format I converted all numeric fields to number format with 2 decimal places.
  3. I import the data into R using the import (rio package)

IMPORT RAW DATA

library(rio)
data = rio::import("C:/Users/Manfred Kuhn/Documents/Rwanda IFRS 9 Data/IFRS data sets/Final Data Sets/RWANDA_JUL19_FINAL_REMEDIATEDv6.csv",integer64 = "double")

I have a column called OS_Balance (meaning outstanding balance) expected result (as formatted in excel)

1.00
1.00
1.00
1.00
1.00
1.00
1.00

actual result

1.00
1.00
1.00
1
1
1
1

When I export the data, the data is exported without any decimal places

Community
  • 1
  • 1
Manfred
  • 147
  • 2
  • 10
  • See if [this](https://stackoverflow.com/questions/44854595/r-how-to-retain-more-decimal-places-when-importing-data-from-a-csv-file?noredirect=1&lq=1) can help you. – deepseefan Sep 14 '19 at 16:43
  • Thank you for the response. There problem here is that within the same variable in the data set, outstanding balance, R sometimes shows 1 decimal, sometime no decimal, sometimes 2 decimals e.g. 1, 1.00, 3487.0. 34898.00 – Manfred Sep 14 '19 at 18:34
  • Could you please give the object type in R of the two vectors ? If it is possible to give the first line of your document and specifying where is exactly your problem, it will be perfect. Thanks – Rémi Coulaud Sep 14 '19 at 20:47
  • the object type for the Outstanding Balance Column is numeric – Manfred Sep 16 '19 at 09:57

1 Answers1

-1

You already try import your data with function 'read.csv()'?