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, immediate. = FALSE, domain = NULL)
     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.

immediate.: logical, indicating if the call should be output
          immediately, even if 'getOption(warn) = 0'.

    expr: expression to evaluate.

  domain: see 'gettext'. If 'NA', messages will not be translated.

_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. 
     Calling 'warning(immediate. = TRUE)' turns 'warn = 0' into 'warn =
     1' for this call only.

     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.

     An attempt is made to coerce other types of inputs to 'warning' to
     character vectors.

     '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='.

     'gettext' for the mechanisms for the automated translation of
     messages.

_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"))

