restoreObjects: Restore Session Objects

Description Usage Arguments Value Author(s) Examples

Description

Restores the objects from an R binary file to the specified environment.

Usage

1
restoreObjects(file = "session.RData", envir = .GlobalEnv, clean = TRUE)

Arguments

file

path to an R binary file

envir

the environment into which the objects should be restored.

clean

boolean indicating whether the environment should be purged prior to restoring objects

Value

This method is executed for it's side-effects.

Author(s)

Matthew D. Furia matt.furia@sagebase.org

https://github.com/MattNapsAlot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## make some objects
aMatrix <- diag(10)
letters <- c("a", "b", "c")

## save the session
sessionFile <- tempfile(fileext=".rbin")
saveSession(list = ls(), file = sessionFile)

## create an environment where they can be restored
env <- new.env()

## assign an object
assign("goo", 1:10, envir = env)

## restore the objects leaving "goo"
restoreObjects(file = sessionFile, envir = env, clean = FALSE)
ls(env)

## restore the objects again, this time delete all objects from env first
restoreObjects(file = sessionFile, envir = env, clean = TRUE)
ls(env)

Sage-Bionetworks/sessionTools documentation built on May 9, 2019, 12:13 p.m.