ID EN
I/O & Files

warning

R Base 3.6.2

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

Syntax

R
warning(…, call. = TRUE, immediate. = FALSE, noBreaks. = FALSE,
        domain = NULL)
suppressWarnings(expr)

Arguments

Parameter Description
… zero or more objects which can be coerced to character (and which are pasted together with no separator) or a single condition object.
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.
noBreaks. logical, indicating as far as possible the message should be output as a single line when options(warn = 1).
expr expression to evaluate.
domain see gettext. If NA, messages will not be translated, see also the note in stop.

Return Value

The warning message as character string, invisibly.

Details

The result depends on the value of options("warn") and on handlers established in the executing code. If a condition object is supplied it should be the only argument, and further arguments will be ignored, with a message. warning signals a warning condition by (effectively) calling signalCondition. If there are no handlers or if all handlers return, then the value of warn = getOption("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 read-only

Examples

Example
R
# NOT RUN {
testit <- function() warning("testit")
testit() ## shows call
testit <- function() warning("problem in testit", call. = FALSE)
testit() ## no call
suppressWarnings(warning("testit"))
# }

See Also

stop for fatal errors message for diagnostic messages warnings and options with argument warn=. gettext for the mechanisms for the automated translation of messages.