The attach function is generic (see Methods); objects that the default method handles include directories, lists (and other recursive S-PLUS objects), compiled databases (see cdump) and user-defined databases (see dbread). In addition methods exists for objects of class: pframe and data.frame.
attach(what, ...) attach.default(what = NULL, pos = 2, name = <<see below>>) attach search()
search returns the names of the search list.
This is not an ordinary dataset, and is accessible only via the functions search and database.object. If errors occur during the top level expression containing the call to attach, the changes will be backed out and the previous search list re-installed. However, a call to synchronize commits the new search list. Errors after this will not back out changes occuring before the synchronize call.
S-PLUS objects can be attached to the search list if they are recursive and all of their components have names. Uniqueness of the names is not enforced-only one component with a particular name will be used. It can be particularly useful to attach data frames.
Assignments to an attached object are allowed in any position, provided that you have write permission. The underlying object is not updated until the object itself is removed from the search list, either by using detach or by quitting S-PLUS. At this time, the revised object will be written back to the file from which it came at the time it was attached.
Note that using a tilde or an environmental variable to specify the first part of a path (e.g., ~cathy/.Data or $HOME/.Data) will not work with attach. These are shell constructs and attach does not use a shell to process the file names.
You may find it useful to put one or more calls to attach in your .First function to automatically attach directories or objects.
At the beginning of a session with S-PLUS, usually seven data directories are attached: the user's working directory, three system function directories and three system data directories. The working directory will be set via the S_WORK environment variable. By default, it uses the subdirectory .Data of the current directory; if that does not exist it will be .Data in your home directory; and if that does not exist, S-PLUS will create .Data in your home directory.
If you try to attach a (writable) directory that has a more restrictive naming scheme than the computer from which you are running S-PLUS, then you will get a warning that you may not be able to access all of the data that you write to that directory under the original name.
attach("/usr/joe/.Data") # attach Joe's data directory in position 2 attach("/usr/joe/.Data", pos = 1) amp;# attach Joe's data directory as the working directory attach(wafer) # attach a data frame search() # what is current search list?