Utilities for Use with S-PLUS Databases

DESCRIPTION:
These functions give information about attached databases. The functions database.status and database.attr can also be used to change the status or an attribute of an attached database.

USAGE:
database.object(where)
database.type(where)
database.status(where)
database.status(where) <- value
database.attr(which, where=1:length(search()))
database.attr(which, where) <-  value

REQUIRED ARGUMENTS:
where:
numeric position in the search list where the database is to be found. In the case of database.attr, where is a vector of database positions that are searched in turn for the requested attribute. Further, if database.attr is being used to find the value of an attribute, it will search the entire string if where is not specified.
which:
the name of the attribute to be extracted or set in the database.
value:
the new value for the attribute.

VALUE:
database.object returns the actual object attached in the whereth position of the search list.

database.type returns a character string describing the type of database at the where position in the search list: "directory", an ordinary directory containing S-PLUS objects; "object", an S-PLUS object (list); "compiled", a compiled object (see function cdump); "user", a user-defined database (see dbread).

database.status returns a character string giving the status of a database: "read", a read-only database; "readwrite", a database that can be read and modified; "modified", a database that has been modified since it was attached.

database.attr returns the value of the attribute named which corresponding to the first database position in where that has such an attribute (or NULL if the attribute does not exist).


SIDE EFFECTS:
if on the left of an assignment database.status can change the status of a database to value

if on the left of an assignment database.attr changes the attribute named what corresponding to the first database position in where to value.


DETAILS:
A permanent, recursive S-PLUS object (typically an expression or a list) can be attached as an element in the search list. The elements of the object become available as separate named objects, referenced by the corresponding elements of the names attribute of the attached recursive object. These databases can be used just like any other S-PLUS database: data access, assignment and modification should take place normally. The potential advantages of using S-PLUS objects as databases are that they make access of objects faster, and that they retain their identity as S-PLUS objects so that a variety of programming techniques become available for them, including the use of methods.

SEE ALSO:
attach , detach , objects , dbread , cdump .

EXAMPLES:
a <- scan("mydata",list(name="",salary=1,age=1,dept=""))
attach(a)  # now the elements available by name
name[salary>100000]