def                  package:svMisc                  R Documentation

_D_e_f_i_n_e _a _v_e_c_t_o_r _o_f _a _g_i_v_e_n _m_o_d_e _a_n_d _l_e_n_g_t_h (_p_o_s_s_i_b_l_y _f_i_l_l_i_n_g _i_t _w_i_t_h _d_e_f_a_u_l_t _v_a_l_u_e_s)

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

     This function makes sure that a vector of a given mode and length
     is returned. If the value provided is NULL, NA, or empty, a
     default value is used instead. If 'length = NULL', the length of
     the vector is not constrained, otherwise, it is fixed (possibly
     cutting or recycling 'value').

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

         def(value, default = "", mode = "character", length = NULL)

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

   value: the value to pass with default 

 default: the default value to use, in case of NULL, NA, or length == 0 

    mode: the mode of the result: character, logical, numeric, complex
          or factor. Other modes are NOT coerced! 

  length: the desired length of the returned vector; use 'length =
          NULL' (default) if you don't want to change the length of the
          vector, i.e., keep same length as 'value'.

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

     A vector of given mode and length, with either 'value' or
     'default'.

_A_u_t_h_o_r(_s):

     Philippe Grosjean <phgrosjean@sciviews.org>

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

     'getTemp', 'assignTemp'

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

     def(1:3, length = 5)                      # Convert into character and recycle
     def(0:2, mode = "logical")                # Numbers to logical
     def(c("TRUE", "FALSE"), mode = "logical") # Text to logical
     def(NULL, "default text")                 # Default value used
     def(character(0), "default text")         # Idem
     def(NA, 10, mode = "numeric", length = 2) # Vector of two numbers

