EVOLUTION-MANAGER
Edit File: warnings.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Print Warning Messages</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for warnings {base}"><tr><td>warnings {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Print Warning Messages</h2> <h3>Description</h3> <p><code>warnings</code> and its <code>print</code> method print the variable <code>last.warning</code> in a pleasing form. </p> <h3>Usage</h3> <pre> warnings(...) ## S3 method for class 'warnings' summary(object, ...) ## S3 method for class 'warnings' print(x, tags, header = ngettext(n, "Warning message:\n", "Warning messages:\n"), ...) ## S3 method for class 'summary.warnings' print(x, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>arguments to be passed to <code><a href="cat.html">cat</a></code> (for <code>warnings()</code>).</p> </td></tr> <tr valign="top"><td><code>object</code></td> <td> <p>a <code>"warnings"</code> object as returned by <code>warnings()</code>.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>a <code>"warnings"</code> or <code>"summary.warnings"</code> object.</p> </td></tr> <tr valign="top"><td><code>tags</code></td> <td> <p>if not <code><a href="missing.html">missing</a></code>, a <code><a href="character.html">character</a></code> vector of the same <code><a href="length.html">length</a></code> as <code>x</code>, to “label” the messages. Defaults to <code>paste0(seq_len(n), ": ")</code> for <i>n >= 2</i> where <code>n <- length(x)</code>.</p> </td></tr> <tr valign="top"><td><code>header</code></td> <td> <p>a character string <code><a href="cat.html">cat</a>()</code>ed before the messages are printed.</p> </td></tr> </table> <h3>Details</h3> <p>See the description of <code><a href="options.html">options</a>("warn")</code> for the circumstances under which there is a <code>last.warning</code> object and <code>warnings()</code> is used. In essence this is if <code>options(warn = 0)</code> and <code>warning</code> has been called at least once. </p> <p>Note that the <code><a href="length.html">length</a>(last.warning)</code> is maximally <code><a href="options.html">getOption</a>("nwarnings")</code> (at the time the warnings are generated) which is <code>50</code> by default. To increase, use something like </p> <pre> options(nwarnings = 10000) </pre> <p>It is possible that <code>last.warning</code> refers to the last recorded warning and not to the last warning, for example if <code>options(warn)</code> has been changed or if a catastrophic error occurred. </p> <h3>Value</h3> <p><code>warnings()</code> returns an object of S3 class <code>"warnings"</code>, basically a named <code><a href="list.html">list</a></code>. </p> <p><code>summary(<warnings>)</code> returns a <code>"summary.warnings"</code> object which is basically the <code><a href="list.html">list</a></code> of unique warnings (<code>unique(object)</code>) with a <code>"counts"</code> attribute, somewhat experimentally. </p> <h3>Warning</h3> <p>It is undocumented where <code>last.warning</code> is stored nor that it is visible, and this is subject to change. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="warning.html">warning</a></code>. </p> <h3>Examples</h3> <pre> ## NB this example is intended to be pasted in, ## rather than run by example() ow <- options("warn") for(w in -1:1) { options(warn = w); cat("\n warn =", w, "\n") for(i in 1:3) { cat(i,"..\n"); m <- matrix(1:7, 3,4) } cat("--=--=--\n") } ## at the end prints all three warnings, from the 'option(warn = 0)' above options(ow) # reset to previous, typically 'warn = 0' tail(warnings(), 2) # see the last two warnings only (via '[' method) ## Often the most useful way to look at many warnings: summary(warnings()) op <- options(nwarnings = 10000) ## <- get "full statistics" x <- 1:36; for(n in 1:13) for(m in 1:12) A <- matrix(x, n,m) # There were 105 warnings ... summary(warnings()) options(op) # revert to previous (keeping 50 messages by default) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>