warning                 package:base                 R Documentation

_W_a_r_n_i_n_g _M_e_s_s_a_g_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Generates a warning message that corresponds to its argument(s)
     and (optionally) the expression or function from which it was
     called.

_U_s_a_g_e:

     warning(..., call. = TRUE)
     suppressWarnings(expr)

_A_r_g_u_m_e_n_t_s:

     ...: character vectors (which are pasted together with no
          separator), a condition object, or 'NULL'.

   call.: logical, indicating if the call should become part of the
          warning message.

    expr: expression to evaluate.

_D_e_t_a_i_l_s:

     The result _depends_ on the value of 'options("warn")' and on
     handlers established in the executing code.

     'warning' signals a warning condition by (effectively) calling
     'signalCondition'.  If there are no handlers or if all handlers
     return, then the value of 'warn' is used to determine the
     appropriate action.  If 'warn' is negative warnings are ignored;
     if it is zero they are stored and printed after the top-level
     function has completed; if it is one they are printed as they
     occur and if it is 2 (or larger) warnings are turned into errors.

     If 'warn' is zero (the default), a top-level variable
     'last.warning' is created.  It contains the warnings which can be
     printed via a call to 'warnings'.

     Warnings will be truncated to 'getOption("warning.length")'
     characters, default 1000.

     While the warning is being processed, a 'muffleWarning' restart is
     available.  If this restart is invoked with 'invokeRestart', then
     'warning' returns immediately.

     'suppressWarnings' evaluates its expression in a context that
     ignores all warnings.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'stop' for fatal errors, 'warnings', and 'options' with argument
     'warn='.

_E_x_a_m_p_l_e_s:

     testit <- function() warning("testit")
     testit() ## shows call
     testit <- function() warning("problem in testit", call. = FALSE)
     testit() ## no call
     suppressWarnings(warning("testit"))

