[R] specify the number of decimal numbers

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Thu May 14 16:41:39 CEST 2009


(Ted Harding) wrote:
> On 14-May-09 12:27:40, Wacek Kusnierczyk wrote:
>   
>>
>> ... but remember that sprintf introduces excel bugs into r (i.e.,
>> rounding is not done according to the  IEC 60559 standard, see ?round):
>>
>>     ns = c(0.05, 0.15)
>>     round(ns, 1)
>>     # 0.0 0.2
>>     as.numeric(sprintf('%.1f', ns))
>>     # 0.1 0.1
>> vQ
>>     
>
> True! And thanks for importing that point into the discussion.
>   

said but true, true but sad.  i have already raised the issue on this
list earlier, but to no response.  apparently, this sort of excel bug in
r is an intentional feature, so you may not get it improved anytime
soon.  unless you submit a patch and get it accepted, that is.

vQ




More information about the R-help mailing list