Learn R Programming

session (version 1.0.3)

save.session: Save and restore session information, including loaded packages and attached data objects.

Description

Save and restore session information, including loaded packages and attached data objects.

Usage

save.session(file=".RSession", ...)
restore.session(file=".RSession", ...)

Arguments

file
Filename for the session information.
...
Optional arguments for save() or load().

Value

  • No return value.

Details

These two functions save and restore R session information. In addition to the objects in the session, the list of currently loaded packages and the search path are (re)stored.

Open graphics devices, sinkss, pipes, etc. will not be stored. save.session issues a warning to this effect if any graphics devices are open.

See Also

save, save.image, load

Examples

Run this code
ls(all=TRUE) # show all data objects
  search()  # list search path

  # save the current R session to the file "RSession.Rda"
  save.session("RSession.Rda")

  # exit R without saving data
  q("no")

  # restart R
  R

  # load a saved R session from "RSession.Rda"
  restore.session("RSession.Rda")

  ls(all=TRUE) # show all data objects
  search()  # list search path

Run the code above in your browser using DataLab