

   quit {base}                                  R Documentation

   TTeerrmmiinnaattee aann RR SSeessssiioonn

   DDeessccrriippttiioonn::

        The function `quit' or its alias `q' terminate the cur-
        rent R session.

   UUssaaggee::

        quit(save = "default", status = 0, runLast = TRUE)
           q(save = "default", status = 0, runLast = TRUE)
        .Last <- function(x) { ...... }

   AArrgguummeennttss::

       save: a character string indicating whether the environ-
             ment (workspace) should be saved, one of `"no"',
             `"yes"', `"ask"' or `"default"'.

     status: the (numerical) error status to be returned to the
             operating system, where relevant. Conventionally
             `0' indicates successful completion.

    runLast: should `.Last()' be executed?

   DDeettaaiillss::

        `save' must be one of `"no"', `"yes"', `"ask"' or
        `"default"'.  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 not to quit.  The
        default is to ask in interactive use but may be over-
        ridden by command-line arguments (which must be sup-
        plied in non-interactive use).

        Immediately before terminating, the function `.Last()'
        is executed if it exists and `runLast' is true. If in
        interactive use there are errors in the `.Last' func-
        tion, control will be returned to the command prompt,
        so do test the function thoroughly.

        Some error statuses are used by R itself.  The default
        error handler for non-interactive effectively calls
        `q("no", 1,      FALSE)' and returns error code 1.
        Error status 2 is used for R `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.

        Valid values of `status' are system-dependent, but
        `0:255' are normally valid.

   SSeeee AAllssoo::

        `.First' for setting things on startup.

   EExxaammpplleess::

        ## Unix-flavour example
        .Last <- function() {
          cat("Now sending PostScript graphics to the printer:\n")
          system("lpr Rplots.ps")
          cat("bye bye...\n")
        }
        quit("yes")

