

   FFlleexxiibbllee FFoorrmmaattttiinngg

        formatC(x, digits = NULL, width = max(0, digits) + 1,
                format = NULL, flag = "", mode = NULL)

   AArrgguummeennttss::

          x: an atomic numerical or character object, typically
             a vector of real numbers.

     digits: the desired number of digits after the decimal
             point. Default: 2 for integer, 4 for real numbers.
             If less than 0, the C default of 6 digits is used.

      width: the total field width; `width < 0' means left jus-
             tify the number in this field (equivalent to `flag
             ="-"').  It is possible that the result will be
             longer than this, but that should only happen in
             reasonable cases.

     format: equal to `"d"'  (for integers), `"f"', `"e"',
             `"E"', `"g"', `"G"' (for reals), or `"s"' (for
             strings).  `"f"' gives numbers in the usual
             ``xxx.xxx'' format; `"e"' and `"E"' give
             ``n.dddenn'' or ``n.dddEnn'' (scientific format);
             `"g"' and `"G"' put `x[i]' into scientific format
             only if it saves space to do so.

       flag: format modifier as in Kernighan and Ritchie, 2nd
             ed., page 243.  `"0"'  pads leading zeros; `"-"'
             does left adjustment, others are `"+"', `" "', and
             `"#"'.

       mode: `"real"',  `"integer"' or `"character"'.  Default:
             Automatic.

   VVaalluuee::

        A character object of same size and attributes as `x'.
        Unlike `format', each number is formatted individually.
        A for loop over each element of `x', calling
        `sprintf(...)' is done in the C function `str_signif'.

        For character arguments `x', simple (left or right)
        padding with white space is done.

   AAuutthhoorr((ss))::

        Originally written by Bill Dunlap, later much improved
        by Martin Maechler, it was adapted for by Friedrich
        Leisch.

   SSeeee AAllssoo::

        `format'.

   EExxaammpplleess::

        xx  <- pi * 10^(-5:4)
        options(digits = 4)   # only for format
        cbind(format(xx), formatC(xx))
        cbind(formatC(xx, wid = 9, flag = "-"))
        cbind(formatC(xx, dig = 5, wid = 8, format = "f", flag = "0"))

        formatC(c("a", "Abc", "no way"), wid = -7)  # <=> flag = "-"

