EVOLUTION-MANAGER
Edit File: last_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: Display last warnings</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 last_warnings {rlang}"><tr><td>last_warnings {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Display last warnings</h2> <h3>Description</h3> <p><code>last_warnings()</code> and <code>last_messages()</code> return a list of all warnings and messages that occurred during the last R command. </p> <p><code><a href="global_entrace.html">global_entrace()</a></code> must be active in order to log the messages and warnings. </p> <p>By default the warnings and messages are printed with a simplified backtrace, like <code><a href="last_error.html">last_error()</a></code>. Use <code>summary()</code> to print the conditions with a full backtrace. </p> <h3>Usage</h3> <pre> last_warnings(n = NULL) last_messages(n = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>n</code></td> <td> <p>How many warnings or messages to display. Defaults to all.</p> </td></tr> </table> <h3>Examples</h3> <p>Enable backtrace capture with <code>global_entrace()</code>: </p> <div class="sourceCode r"><pre>global_entrace() </pre></div> <p>Signal some warnings in nested functions. The warnings inform about which function emitted a warning but they don't provide information about the call stack: </p> <div class="sourceCode r"><pre>f <- function() { warning("foo"); g() } g <- function() { warning("bar", immediate. = TRUE); h() } h <- function() warning("baz") f() #> Warning in g() : bar #> Warning messages: #> 1: In f() : foo #> 2: In h() : baz </pre></div> <p>Call <code>last_warnings()</code> to see backtraces for each of these warnings: </p> <div class="sourceCode r"><pre>last_warnings() #> [[1]] #> <warning/rlang_warning> #> Warning in `f()`: foo #> Backtrace: #> 1. global f() #> #> [[2]] #> <warning/rlang_warning> #> Warning in `g()`: bar #> Backtrace: #> 1. global f() #> 2. global g() #> #> [[3]] #> <warning/rlang_warning> #> Warning in `h()`: baz #> Backtrace: #> 1. global f() #> 2. global g() #> 3. global h() </pre></div> <p>To get a full backtrace, use <code><a href="../../base/html/summary.html">summary()</a></code>. In this case the full backtraces do not include more information: </p> <div class="sourceCode r"><pre>summary(last_warnings()) #> [[1]] #> <warning/rlang_warning> #> Warning in `f()`: #> foo #> Backtrace: #> x #> 1. \-global f() #> #> [[2]] #> <warning/rlang_warning> #> Warning in `g()`: #> bar #> Backtrace: #> x #> 1. \-global f() #> 2. \-global g() #> #> [[3]] #> <warning/rlang_warning> #> Warning in `h()`: #> baz #> Backtrace: #> x #> 1. \-global f() #> 2. \-global g() #> 3. \-global h() </pre></div> <h3>See Also</h3> <p><code><a href="last_error.html">last_error()</a></code> </p> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>