R: Diagnostic Messages (original) (raw)

message {base} R Documentation

Description

Generate a diagnostic message from its arguments.

Usage

message(..., domain = NULL, appendLF = TRUE)
suppressMessages(expr, classes = "message")

packageStartupMessage(..., domain = NULL, appendLF = TRUE)
suppressPackageStartupMessages(expr)

.makeMessage(..., domain = NULL, appendLF = FALSE)

Arguments

... zero or more objects which can be coerced to character (and which are pasted together with no separator) or (formessage only) a single condition object.
domain see gettext. If NA, messages will not be translated, see also the note in stop.
appendLF logical: should messages given as a character string have a newline appended?
expr expression to evaluate.
classes character, indicating which classes of messages should be suppressed.

Details

message is used for generating ‘simple’ diagnostic messages which are neither warnings nor errors, but nevertheless represented as conditions. Unlike warnings and errors, a final newline is regarded as part of the message, and is optional. The default handler sends the message to the[stderr](../../base/help/stderr.html)() connection.

If a condition object is supplied to message it should be the only argument, and further arguments will be ignored, with a warning.

While the message is being processed, a muffleMessage restart is available.

suppressMessages evaluates its expression in a context that ignores all ‘simple’ diagnostic messages.

packageStartupMessage is a variant whose messages can be suppressed separately by suppressPackageStartupMessages. (They are still messages, so can be suppressed by suppressMessages.)

.makeMessage is a utility used by message, warningand stop to generate a text message from the ...arguments by possible translation (see [gettext](../../base/help/gettext.html)) and concatenation (with no separator).

See Also

[warning](../../base/help/warning.html) and [stop](../../base/help/stop.html) for generating warnings and errors; [conditions](../../base/help/conditions.html) for condition handling and recovery.

[gettext](../../base/help/gettext.html) for the mechanisms for the automated translation of text.

Examples

message("ABC", "DEF")
suppressMessages(message("ABC"))

testit <- function() {
  message("testing package startup messages")
  packageStartupMessage("initializing ...", appendLF = FALSE)
  Sys.sleep(1)
  packageStartupMessage(" done")
}

testit()
suppressPackageStartupMessages(testit())
suppressMessages(testit())

[Package _base_ version 4.6.0 Index]