[R] printing decimal numbers

Marc Schwartz mschwartz at medanalytics.com
Mon Feb 24 18:19:03 CET 2003


>-----Original Message-----
>From: r-help-admin at stat.math.ethz.ch 
>[mailto:r-help-admin at stat.math.ethz.ch] On Behalf Of Thomas Gerds
>Sent: Monday, February 24, 2003 11:01 AM
>To: r-help at stat.math.ethz.ch
>Subject: [R] printing decimal numbers
>
>
>hi,
>
>this is a very basic question -- sorry for posing it:
>     
>how can i force R to print 0.0001 instead of 1e-04???
>
>.--------------------.
>| > 0.0001           |
>| [1] 1e-04          |
>`--------------------'
>
>i tried the functions format, formatC, ... and changed 
>options()$digits with no success!
>
>thanks for advice,
>tomy


Try:

> formatC(0.0001, format = "f", digits = 4)
[1] "0.0001"

Be sure to use the 'format = "f"' argument.

See ?formatC

HTH,

Marc Schwartz




More information about the R-help mailing list