applyTemplate             package:memisc             R Documentation

_A_p_p_l_y _a _F_o_r_m_a_t_t_i_n_g _T_e_m_p_l_a_t_e _t_o _a _N_u_m_e_r_i_c _o_r _C_h_a_r_a_c_t_e_r _V_e_c_t_o_r

_D_e_s_c_r_i_p_t_i_o_n:

     'applyTemplate' is called internally by 'mtable' to format
     coefficients and summary statistics.

_U_s_a_g_e:

     applyTemplate(x,template,float.style=getOption("float.style"),
                           digits=min(3,getOption("digits")),
                           signif.symbols=getOption("signif.symbols"))

_A_r_g_u_m_e_n_t_s:

       x: a numeric or character vector to be formatted

template: a character vector that defines the template, see details.

float.style: A character string that is passed to 'formatC' by
          'applyTemplate'; valid values are '"e"', '"f"', '"g"',
          '"fg"', '"E"', and '"G"'. By default, the 'float.style' 
          setting of 'options' is used. The `factory fresh' setting is
          'options(float.style="f")' 

  digits: number of significant digits to use if not specified in the
          template.

signif.symbols: a named vector that specifies how significance levels
          are symbolically indicated, values of the vector specify
          significance levels and names specify the symbols. By
          default, the  'signif.symbols' setting of 'options' is used.
          The "factory-fresh" setting is
          'options(signif.symbols=c("***"=.001,"**"=.01,"*"=.05))'. 

_D_e_t_a_i_l_s:

     Character vectors that are used as templates may be arbitrary.
     However, certain character sequences may form _template
     expressions_. A template expression is of the form
     '($<POS>:<Format spec>)', where "'($'" indicates the start of a
     template expression, "'<POS>'" stands for either an index or name
     that selects an element from 'x' and "'<Format spec>'" stands for
     a _format specifier_. It may contain an letter indicating the
     style in which the vector element selected by '<POS>' will be
     formatted by 'formatC', it may contain a number as the number of
     significant digits, a "'#'" indicating that the number of
     signifcant digits will be at most that given by
     'getOption("digits")', or '*' that means that the value will be
     formatted as a significance symbol.

_V_a_l_u_e:

     'applyTemplate' returns a character vector in which template
     expressions in 'template' are substituted by formatted values from
     'x'. If 'template' is an array then the return value is also an
     array of the same shape.

_E_x_a_m_p_l_e_s:

     applyTemplate(c(a=.0000000000000304,b=3),template=c("($1:g7#)($a:*)"," (($1:f2)) "))
     applyTemplate(c(a=.0000000000000304,b=3),template=c("($a:g7#)($a:*)"," (($b:f2)) "))

