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.
write_csv2andwrite_excel_csv2don't preserve the precision of decimal numbers in exported csv files, regardless of the current value of thegetOption("digits"), as opposed towrite_csvandwrite_excel_csv.Since this is happening because of the transformation performed by
change_decimal_separator, I hope this counts as a reproducible example:For reference, both
utils::write.csv2anddata.table::fwritewith argumentsdec = ","andsep = ";"also preserve the decimal numbers.