EVOLUTION-MANAGER
Edit File: quit.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: Terminate an R Session</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 quit {base}"><tr><td>quit {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Terminate an R Session</h2> <h3>Description</h3> <p>The function <code>quit</code> or its alias <code>q</code> terminate the current <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> session. </p> <h3>Usage</h3> <pre> quit(save = "default", status = 0, runLast = TRUE) q(save = "default", status = 0, runLast = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>save</code></td> <td> <p>a character string indicating whether the environment (workspace) should be saved, one of <code>"no"</code>, <code>"yes"</code>, <code>"ask"</code> or <code>"default"</code>.</p> </td></tr> <tr valign="top"><td><code>status</code></td> <td> <p>the (numerical) error status to be returned to the operating system, where relevant. Conventionally <code>0</code> indicates successful completion.</p> </td></tr> <tr valign="top"><td><code>runLast</code></td> <td> <p>should <code>.Last()</code> be executed?</p> </td></tr> </table> <h3>Details</h3> <p><code>save</code> must be one of <code>"no"</code>, <code>"yes"</code>, <code>"ask"</code> or <code>"default"</code>. In the first case the workspace is not saved, in the second it is saved and in the third the user is prompted and can also decide <em>not</em> to quit. The default is to ask in interactive use but may be overridden by command-line arguments (which must be supplied in non-interactive use). </p> <p>Immediately <em>before</em> normal termination, <code>.Last()</code> is executed if the function <code>.Last</code> exists and <code>runLast</code> is true. If in interactive use there are errors in the <code>.Last</code> function, control will be returned to the command prompt, so do test the function thoroughly. There is a system analogue, <code>.Last.sys()</code>, which is run after <code>.Last()</code> if <code>runLast</code> is true. </p> <p>Exactly what happens at termination of an <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> session depends on the platform and GUI interface in use. A typical sequence is to run <code>.Last()</code> and <code>.Last.sys()</code> (unless <code>runLast</code> is false), to save the workspace if requested (and in most cases also to save the session history: see <code><a href="../../utils/html/savehistory.html">savehistory</a></code>), then run any finalizers (see <code><a href="reg.finalizer.html">reg.finalizer</a></code>) that have been set to be run on exit, close all open graphics devices, remove the session temporary directory and print any remaining warnings (e.g., from <code>.Last()</code> and device closure). </p> <p>Some error status values are used by <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> itself. The default error handler for non-interactive use effectively calls <code>q("no", 1, FALSE)</code> and returns error status 1. Error status 2 is used for <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> ‘suicide’, that is a catastrophic failure, and other small numbers are used by specific ports for initialization failures. It is recommended that users choose statuses of 10 or more. </p> <p>Valid values of <code>status</code> are system-dependent, but <code>0:255</code> are normally valid. (Many OSes will report the last byte of the value, that is report the value modulo 256. But not all.) </p> <h3>Warning</h3> <p>The value of <code>.Last</code> is for the end user to control: as it can be replaced later in the session, it cannot safely be used programmatically, e.g. by a package. The other way to set code to be run at the end of the session is to use a <em>finalizer</em>: see <code><a href="reg.finalizer.html">reg.finalizer</a></code>. </p> <h3>Note</h3> <p>The <code>R.app</code> GUI on macOS has its own version of these functions with slightly different behaviour for the <code>save</code> argument (the GUI's ‘Startup’ preferences for this action are taken into account). </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="Startup.html">.First</a></code> for setting things on startup. </p> <h3>Examples</h3> <pre> ## Not run: ## Unix-flavour example .Last <- function() { graphics.off() # close devices before printing cat("Now sending PDF graphics to the printer:\n") system("lpr Rplots.pdf") cat("bye bye...\n") } quit("yes") ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>