[R] No scientific notation in format

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jan 24 13:21:40 CET 2006


Did you miss the 'sci' argument to format()?

On Tue, 24 Jan 2006, Richard van Wingerden wrote:

> Hi
>
> I have a data.frame with the following numbers (first column are month
> numbers)
>
> 07,0,0,0,0.315444056314174,0,0,0,12.5827462764176,0.079194498691732,
> 0.0280828101707015,0,0.0695808222378877
> 08,0,0,105600,0.393061160316545,0,0,0,8.95551253153947,0.0880023174276553,
> 0.285714285714286,0,0.0669139911789158
> 09,0,0,0,0,12.5,0,0,13.5135887094281,0.0557531529154668,0,0,
> 0.0487526139182026
> 10,0,0,0.475889042117876,0,0,0,0,10.0845573786599,0.102517312169950,0,0,
> 0.153967527953265
>
> When I write this to csv (with write.csv) R makes this of it:
> 07,0,0,0.00000e+00,0.3154441, 0.0,0,0,12.582746,0.07919450,0.02808281,0,
> 0.06958082
> 08,0,0,1.05600e+05,0.3930612, 0.0,0,0, 8.955513,0.08800232,0.28571429,0,
> 0.06691399
> 09,0,0,0.00000e+00,0.0000000,12.5,0,0,13.513589,0.05575315,0.00000000,0,
> 0.04875261
> 10,0,0,4.75889e-01,0.0000000, 0.0,0,0,10.084557,0.10251731,0.00000000,0,
> 0.15396753
>
> I am using data_frame <- format(data_frame, trim = TRUE, digits = 3, nsmall
> = 4, width = 5) for format.
> And data_frame <- formatC(data_frame, digits = 3, width = 4, format = "f",
> mode = NULL) leads to the following error:
> Error in as.integer.default(floor(log10(abs(x + ifelse(x == 0, 1, 0))))) :
>        (list) object cannot be coerced to 'integer'
>
> How do I get rid of the 'e+00' notation?
> Thanks in advance for you help.
>
> Regards,
> Richard
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list