[R] Format wanted...
murdoch.duncan at gmail.com
Sun Mar 25 14:14:42 CEST 2012
On 12-03-24 10:47 PM, J Toll wrote:
> On Sat, Mar 24, 2012 at 7:30 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com> wrote:
>> Do we have a format that always includes a decimal point and a given number
>> of significant digits, but otherwise drops unnecessary characters? For
>> example, if I wanted 5 digits, I'd want the following:
>> Round to 5 digits:
>> 1.234567 -> "1.2346"
>> Drop unnecessary zeros:
>> 1.23 -> "1.23"
>> Force inclusion of a decimal point:
>> 1 -> "1."
> Maybe sprintf() will work for you. As it's a wrapper for C sprintf,
> it should have its functionality.
Maybe, but with which format string?
More information about the R-help