extendrange            package:grDevices            R Documentation

_E_x_t_e_n_d _a _N_u_m_e_r_i_c_a_l _R_a_n_g_e _b_y _a _S_m_a_l_l _P_e_r_c_e_n_t_a_g_e

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

     Extends a numerical range by a small percentage, i.e., fraction,
     _on both sides_.

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

     extendrange(x, r = range(x, na.rm = TRUE), f = 0.05)

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

       x: numeric vector; not used if 'r' is specified.

       r: numeric vector of length 2; defaults to the 'range' of 'x'.

       f: number specifying the fraction by which the range should be
          extended.

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

     A numeric vector of length 2, 'r + c(-f,f) * diff(r)'.

_S_e_e _A_l_s_o:

     'range'; 'pretty' which can be considered a sophisticated
     extension of 'extendrange'.

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

     x <- 1:5
     (r <- range(x))         # 1    5
     extendrange(x)          # 0.8  5.2
     extendrange(x, f= 0.01) # 0.96 5.04
     ## Use 'r' if you have it already:
     stopifnot(identical(extendrange(r=r),
                         extendrange(x)))

