Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

onSessionExit

Registers a function to be called when the R session finishes


Description

Registers a function to be called when the R session finishes.

Usage

## Default S3 method:
onSessionExit(fcn, action=c("prepend", "append", "replace"), ...)

Arguments

fcn

A function to be called without argument.

action

A character string specifying how the hook function is added to list of hooks.

...

Not used.

Details

Functions registered this way are called when finalizeSession() is called. Moreover, when this package is loaded, the .Last() function is modified such that finalizeSession() is called. However, note that .Last() is not guaranteed to be called when the R session finished. For instance, the user may quit R by calling quit(callLast=FALSE). Moreover, when R is run in batch mode, .Last() is never called.

Value

Returns (invisibly) the hooks successfully called.

Author(s)

Henrik Bengtsson

See Also

Examples

## Not run: 
  onSessionExit(function(...) {
    message("Bye bye world!")
  })

  quit()

## End(Not run)

R.utils

Various Programming Utilities

v2.10.1
LGPL (>= 2.1)
Authors
Henrik Bengtsson [aut, cre, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.