loadws {rwm}R Documentation

load workspace

Description

Loads R workspace and history. Move to workspace directory.

Usage

loadws(name = "", d = as.character(.UserDate), silentQ = FALSE, 
historyQ = TRUE, clearQ = TRUE, prefix = .Prefix, pos=1)

Arguments

name name of workspace to load and move to or if name = "", move to directory specified by .UserDirectory <> d
d an optional subdirectory of .UserDirectory, usually set to year
silentQ TRUE, no message
historyQ TRUE, load R history
clearQ TRUE, clear all R objects before loading the workspace
prefix If non-null and valid file name, prefix is prepended to .Rdata. If .Prefix is undefined, NULL prefix is used.
pos position in search path. When pos=1, the workspace becomes the global environment or root workspace. For pos=2, the workspace is simply attached at position 2 using the attachws. And pos>2, results in an error.

Details

This simply uses the R base functions load and loadhistory to load the R workspace and command history specified by the arguments. Normally all R objects are removed using clearws(silent=TRUE) before loading the workspace.

The working directory is set the the workspace working directory unless name is the null string. In this case, the current directory is set to .UserDirectory<>d.

An error message is given if .UserDirectory is not defined. The .UserDirectory may be set manually using a normal R assignment or by the function initrwm().

If the workspace contains a character vector .Describe, this is also displayed when the workspace is loaded. .Describe may contain a brief description of the purpose of the workspace and/or major functions/datasets in the workspace.

Value

The global variable .WSID is set to the current working directory.

Warning

In the unlikely event that the workspace being loaded already happens to contain one of the objects loadws, savews, clearws or cws a warning will be given and the object will be deleted.

Author(s)

A.I. McLeod

See Also

attachws, load, savews, clearws, initrwm

Examples

#INITIALIZATION
#Normally .UserDirectory and .UserDate are defined previously. 
#Usually a more convenient directory is used but for illustration
#using a script which will run in interactive or batch mode on any computer:
.UserDirectory <- tempdir()
.UserDate <- "2009"
dir.create(paste(.UserDirectory, .UserDate, sep="/"))

#Example 1. 
#define a new function
is.same.name<-function(x,y) is.logical(all.equal(x,y))&&all.equal(x,y)
#save this workspace as SameName
savews("SameName")
#check .WSID
.WSID
#also save R source file in workspace directory
dump("is.name.same", file="is.name.same.R")
#see all objects in directory
dir(all.files=TRUE)
#Use a prefix with savews
savews("SameName", prefix="MyWorkspace")
dir(all.files=TRUE)


[Package rwm version 1.35 Index]