Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Chris Conner
Sent: Friday, October 14, 2011 10:31 AM
To: Paul Hiemstra
Cc: r-help at r-project.org
Subject: Re: [R] is there an option to "turn off" scientific notation in write.csv
Paul,
Many thanks for your help! I tried the suggestions below and, unfortunately, they didn't work for
me.? I actually tried a tweak even:
Here is what I tried (might I be missing something?):
df$x <-format(df$x, scientific = FALSE)
write.csv(df ,file="df.csv")
df$x <-format(df$x, scientific = FALSE)
write.csv(format(df, scientific = FALSE) ,file="df.csv")
For some reason write.csv still wants to coerce the long numeric into scientific notation prior to
writing the .csv file...
I'm running 2.13.1 on a Win 7 machine... I wonder if this is a bug?
One work around I've figured out is to paste a character to df$x before exporting, then trimming the
character after export... but there has to be a more elegant solution?
________________________________
From: Paul Hiemstra <paul.hiemstra at knmi.nl>
Cc: "r-help at r-project.org" <r-help at r-project.org>
Sent: Friday, October 14, 2011 12:39 AM
Subject: Re: [R] is there an option to "turn off" scientific notation in write.csv
On 10/14/2011 05:25 AM, Chris Conner wrote:
Dear Help-Rs,
I'm working with a file that contains large numbers and I need to export them "as is".? for example
take:
? x <- c(27104010002005,27104020001805,27104090001810,90050013000140,90050013000120)
y <- c(1:5)
df <- data.frame(cbind(x,y))
When I then try a simple:
write.csv(df,file="df.csv")
I get:
?x?y
1?2.7104E+13?1
2?2.7104E+13?2
3?2.71041E+13?3
4?9.005E+13?4
5?9.005E+13?5
Then I tried:
options(scipen=999)
df$x <- as.character(df$x)
Hi,
You can use format in this case:
df$x <-format(df$x, scientific = FALSE)
write.csv(df,file="df.csv")
regards,
Paul
write.csv(df,file="df.csv")
and I still get:
?x?y
1?2.7104E+13?1
2?2.7104E+13?2
3?2.71041E+13?3
4?9.005E+13?4
5?9.005E+13?5
How can I have R write the file so it looks like this:
?x y
1 27104010002005
2 27104020001805
3 27104090001810
4 90050013000140
5 90050013000120 [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-
project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paulhttp://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
[[alternative HTML version deleted]]