store {Hmisc}R Documentation

Store an Object Permanently

Description

By default, store will copy the object to .Data under the same name. This function is most useful when you have attached a data frame or a temporary directory in position 1. store is also useful for setting up to store later objects in a temporary work area (.Data.tempnnnn, where nnnn is a number computed by the system) so that they are not stored on disk. For this usage, just invoke store with no arguments, i.e., store(). After that, you can still invoke store with arguments so that the object is copied to permanent storage. Another function, stores is useful for storing a series of temporary objects in .Data with one call. store and stores are not available For R. See Details below for a method of approximating the use of store in R.

storeTemp stores an object in frame 0 for S-Plus or in a temporary environment .GlobalTemp in R, attaching that environment if it is not already attached, so that the objects are easily available.

Usage

store(object, name=as.character(substitute(object)),
      where=if (under.unix || .SV4.) ".Data" else "_Data")
stores(...)
storeTemp(object, name=deparse(substitute(object)))

Arguments

object object to store (omit to set search list position one to a temporary directory created by store)
name name under which to store the object. Default is name of object in call to store().
where directory in which to store object. Default is .Data underneath current directory (for UNIX) or position 2 in the search list (for Windows). For R the default is .GlobalEnv.
... a list of objects to store in .Data or .GlobalEnv permanently, using names which are the same as the argument names

Details

To almost mimic the functionality of store or stores in R, you can do the following. Use save(x,y,z,file="Permdata") to save permanent objects in "permdata". When you exit R, do not save the workspace. Then all temporary objects will disappear. In your .Rprofile put the command load("Permdata") so that the next time you invoke R the permanent objects will be available.

Side Effects

uses assign and attach functions. store with no arguments also stores a function .Last in .Data.tempnnnn, which will cause .Data.tempnnnn to be removed when the S session ends. For S-Plus, store() causes creation of a system option named .store.temp which contains the name of the temporary directory created.

See Also

assign, .Last, attach, search

Examples

## Not run: 
attach(database, 1)     #this database takes precedence
store()                 #new objects to go under database in memory
                        #this doesn't work in R
f <- lm(y ~ x)
store(f)                #store f under name "f" in .Data or .GlobalEnv
                        #uses assign() with immediate=T
store(f, "final.model") #immediately store f under "final.model" in .Data
store()                 #store future objects in .Data.tempnnnn
x <- runif(1000)        #x will disappear at session end unless
store(x)                #this statement appears -> store in .Data
stores(x, y, z)         #store x,y,z in .Data under names x,y,z
storeTemp(x)            #put x as name 'x' in frame 0
                        #for R, attach .GlobalTemp and store it there
storeTemp(x,'X')        #same as previous but under the name X
## End(Not run)

[Package Hmisc version 3.0-10 Index]