Phdaml Phdaml - 1 year ago 109
R Question

Scientific notation last digits omitted as zeros when write.csv

I have a lot of long numbers and r reads them as scientific notation. But when I

, the scientific notation becomes an incorrect number with a bunch of zeros following. For example,
will become
after the

I have exact numbers in the place where the zeros are.
How do I keep the exact number when exporting a data file?

(1) The problem is because when I save as csv in excel, it loses digits of long numbers. It is an excel bug and I use excel 2016.

(2) when the above problem occurred, I tired to set
. When I summarize the data, the summary statistics are omitted always in this file. I tried other files, it (
) works without losing precision. When I do print the numbers, it is correct, only the summary statistics are omitted after I set options.

Answer Source

Set the the scipen option to be a large enough number before writing the csv file is one way to make it work:

df = data.frame(x = 1232939143546532)
options(scipen = 30)
write.csv(df, "")

This gives the following:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download