format                 package:base                 R Documentation

_E_n_c_o_d_e _i_n _a _C_o_m_m_o_n _F_o_r_m_a_t

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_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 magnitude) number has this many
          significant digits.

_D_e_t_a_i_l_s:

     These functions convert their first argument to a vector (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, but does not provide a common format for
     several numbers.

_N_o_t_e:

     Currently `format' loses trailing zeroes, so `format(6.001,
     digits=2)' gives `"6"' and `format(c(6.0, 13.1), digits=2)' gives
     `c(" 6", "13")'.

     Character(s) `"' in input strings `x' are escaped to `\"'.

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_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)

