View source: R/shared_class_functions.r
records | R Documentation |
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.
records(x, ...)
records(x, ...) <- value
x |
a relational data object, such as a |
... |
further arguments passed on to methods. |
value |
A list of data frames of the same length as |
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.
A list containing data frames, with elements named for their respective relations.
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]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.