[R] round() and negative digits

Rolf Turner rolf.turner at xtra.co.nz
Sat Oct 8 23:32:28 CEST 2011


On 09/10/11 00:18, Duncan Murdoch wrote:
> On 11-10-07 5:26 PM, Carl Witthoft wrote:
>> Just wondering here -- I tested and found to my delight that
>>
>> %  round(325.4,-2)
>> [1] 300
>>
>> gave me exactly what I would have expected (and wanted).  Since it's not
>> explicitly mentioned in the documentation that negative 'digits' is
>> allowed, I just wanted to ask whether this behavior is intentional or a
>> happy turn of events.  I'm always paranoid that something not explicitly
>> documented might disappear in future revisons.
>>
>
> It is intentional, and one of the regression tests confirms that it's 
> there, so it won't disappear by mistake, and would be very unlikely to 
> disappear intentionally.

Uh, wouldn't it be *nice* to mention this --- not completely obvious --- 
capability
in the help file?

     cheers,

         Rolf



More information about the R-help mailing list