Assign Copies of Objects to a Database

DESCRIPTION:
Assigns copies of S-PLUS objects to (another) database.

USAGE:
objcopy(names, where.new, new.names=names, where.old=1, overwrite=F)

REQUIRED ARGUMENTS:
names:
character vector giving the names of existing objects to be copied.
where.new:
the database to which the copies should be assigned. where.new can be either a number or an object defining a database. A number is interpreted as the corresponding element of the search list. See the helpfile for assign for more details.

OPTIONAL ARGUMENTS:
new.names:
character vector giving the names under which the copies should be assigned. By default these are the same as the original names.
where.old:
the database where the original objects live.
overwrite:
logical flag specifying whether existing objects on where.new should be overwritten. If any of new.names exist already on where.new and overwrite=FALSE, an error is generated and nothing is assigned.

VALUE:
new.names is invisibly returned.

SIDE EFFECTS:
duplicates of names are assigned on database where.new under new.names.

NOTES:
The database where.new must be writeable.

Assignments by objcopy are committed only when the current top-level expression completes without error, or when synchronize is used.

This function is unrelated to the copy function in the S-PLUS library section external.


SEE ALSO:
Assignment , assign , get , synchronize , find , dump .

EXAMPLES:
z <- z    # find z somewhere and make a copy on the working database
objcopy("x", 2)         # copy x from database 1 to database 2
assign("x", get("x", where=1), where=2)   # Same thing.
assign("x", x, where=2) # Same thing, if x is found on database 1.
objcopy("x", 2, "y")    # copy x from d.b. 1 to d.b. 2 under name y
assign("y", get("x", where=1), where=2)   # Same thing.
assign("y", x, where=2) # Same thing, if x is found on database 1.
objcopy(c("X", "Y", "Z"), 2)     # copy all three from d.b. 1 to d.b. 2
old.names <- c("X", "Y", "Z")
objcopy(old.names, 1, paste(old.names, "backup", sep="."))
        # make backup copies X.backup etc. on the same database, 1
objcopy("myfun", "S_stash")
        # S_stash is a directory of S-PLUS objects you want to keep.
        # It need not be currently attached.