## Print a couple of cute messages when R exits.
helloWorld <- function() cat("Hello World!
")
byeWorld <- function() cat("Goodbye World!
")
.Last <- lastAdd(byeWorld)
.Last <- lastAdd(helloWorld)
.Last()
q("no")
## Should yield:
##
## Save workspace image? [y/n/c]: n
##
## Hello World!
##
## Goodbye World!
##
## Process R finished at Tue Nov 22 10:28:55 2005
## Unix-flavour example: send Rplots.ps to printer on exit.
myLast <- function()
{
cat("Now sending PostScript graphics to the printer:
")
system("lpr Rplots.ps")
cat("bye bye...
")
}
.Last <- lastAdd(myLast)
.Last()
quit("yes")
## Should yield:
##
## Now sending PostScript graphics to the printer:
## lpr: job 1341 queued
## bye bye...
##
## Process R finished at Tue Nov 22 10:28:55 2005
Run the code above in your browser using DataLab