

   format {base}                                R Documentation

   EEnnccooddee iinn aa CCoommmmoonn FFoorrmmaatt

   DDeessccrriippttiioonn::

        Format an R object for pretty printing: `format.pval'
        is intended for formatting p-values.

   UUssaaggee::

        format(x, ...)
        format.default(x, trim=FALSE, digits = .Options$digits)
        format.pval(x, digits= max(1,.Options$digits-2), eps = .Machine$double.eps)

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

          x: any R object (conceptually); typically numeric.

       trim: logical; if `TRUE', leading blanks are trimmed off
             the strings.

     digits: how many significant digits are to be used for
             `numeric x'. This is a suggestion: enough decimal
             places will be used so that the smallest (in mag-
             nitude) number has this many significant digits.

   DDeettaaiillss::

        These functions convert their first argument to a vec-
        tor (or array) of character strings which have a common
        format (as is done by `print').  The trimming with
        `trim = TRUE' is useful when the strings are to be used
        for plot `axis' annotation.

        `format.pval' is mainly an auxiliary function for
        `print.summary.lm' etc., does separate formatting for
        fixed, floating point and very small values (those `<
        eps').

        The function `formatC' provides a rather more flexible
        formatting facility for numbers, does not provide a
        common format for several numbers, however.

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

        `formatC', `paste', `as.character'.

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

        format(1:10)

        p <- c(47,13,2,.1,.023,.0045, 1e-100)/1000
        format.pval(p)
        format.pval(p / 0.9)
        format.pval(p / 0.9, dig=3)

