Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loss of precision in decimal places in write_csv2 #1087

Closed
fjuniorr opened this issue Mar 29, 2020 · 0 comments
Closed

Loss of precision in decimal places in write_csv2 #1087

fjuniorr opened this issue Mar 29, 2020 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@fjuniorr
Copy link

fjuniorr commented Mar 29, 2020

write_csv2 and write_excel_csv2 don't preserve the precision of decimal numbers in exported csv files, regardless of the current value of the getOption("digits"), as opposed to write_csv and write_excel_csv.

Since this is happening because of the transformation performed by change_decimal_separator, I hope this counts as a reproducible example:

digits <- getOption("digits")

df <- data.frame(value = 1234567.1)

options(digits = 7)
readr:::change_decimal_separator(df)
#>     value
#> 1 1234567

options(digits = 8)
readr:::change_decimal_separator(df)
#>       value
#> 1 1234567,1

options(digits = digits)

For reference, both utils::write.csv2 and data.table::fwrite with arguments dec = "," and sep = ";" also preserve the decimal numbers.

@jimhester jimhester added the bug an unexpected problem or unintended behavior label Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants