[R] Rounding

Martin Maechler maechler at stat.math.ethz.ch
Tue Sep 24 12:36:56 CEST 2002


>>>>> "ChinShCh" == Chin-Shan Chuang <chinshan.chuang at stanfordalumni.org>
>>>>>     on Thu, 19 Sep 2002 07:44:48 -0400 writes:

    ChinShCh> Hi, would taking log base 10 of the number help?
    ChinShCh> For example, a number that's >= 100 and < 1000
    ChinShCh> would have log base 10 >= 2 and < 3.  Use floor on
    ChinShCh> this.

also, Peter Dalgaard's answer in this thread already answers the
question I think.

One thing not widely known you may be able to use is
format.info() :
It indicates how much space  format() would use
--> help(format.info)

    ChinShCh> Ko-Kang Kevin Wang <kwan022 at stat.auckland.ac.nz> wrote:

    KKKW> Now my questions is: how do I work out the number
    KKKW> of digits x has?  For example in this case I have
    KKKW> 3 digits for x (4, 5, and 9), hence I can divide
    KKKW> it by 100 first, floor() or ceiling() the result,
    KKKW> then times 100.

    KKKW> If I have n digits for x, this means I want to divide by (n - 1).  
    KKKW> But I'm not sure how to find n :-(
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list