Learn R Programming

autodb (version 2.3.1)

records: Relational data records

Description

Generic function, for retrieving data contained in a database-like structure. In particular, this is intended for such structures where the individual relations can't be accessed with subsetting.

Usage

records(x, ...)

records(x, ...) <- value

Value

A list containing data frames, with elements named for their respective relations.

Arguments

x

a relational data object, such as a relation or database object.

...

further arguments passed on to methods.

value

A list of data frames of the same length as records(x, ...), where each data frame has the same column names as that which it will replace, in the same order.

Details

Since the relational data objects in autodb, relation and database, have subsetting methods that return relational data objects, the data contained within them can't be accessed by subsetting. This function is intended for accessing it instead.

It's recommended to call records before doing any subsetting, since subsetting on a relation data object does more work that will be thrown away, such as subsetting on a database checking whether foreign key references should be removed.

Examples

Run this code
db <- autodb(ChickWeight)
records(db) # data for Chick and Time_Chick relations

# ways to get data for subsets
records(db)[c(1, 2)]
records(db)[[1]]
records(db)$Chick

# subsetting first isn't recommended: removes foreign key
# reference as mentions, and you need to subset again anyway
records(db[[1]])[[1]]

Run the code above in your browser using DataLab