[R] How do I format something as "0.000"?
Michael Prager
Mike.Prager at noaa.gov
Mon Jan 17 22:13:43 CET 2005
Christian Hennig wrote:
>I would like to use the format function to get numbers all with three
>digits to the right of the decimal point, even in cases where there is no
>significant digit left. For example, I would like to get
>c(0.3456789,0.0000053) as "0.346" "0.000".
I posted a fairly complete example of doing this some time ago. If you
search the list archives under my name, you should be able to find it.
It's not at hand right now, or I would post it again. The key was using
formatC(), but my example had other little issues worked out as well.
MHP
--
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina 28516 USA
http://shrimp.ccfhrb.noaa.gov/~mprager/
More information about the R-help
mailing list