View source: R/shared_class_functions.r
| add_lookup | R Documentation |
Create single-attribute relations for each of a given set of attributes. If the original object also contains references, then the new lookup relations are connected to other appearances of their attribute by chains of references.
add_lookup(x, as, ...)
x |
a relational schema object, such as a |
as |
a character vector of elements from |
... |
further arguments pass on to methods. |
Whether an attribute in as gets a new key relation depends on the
relations already present. An existing relation is considered to be a lookup
if the following hold:
The attribute is a simple key for the relation;
If x is a relation data object, then the relation contains all
given values for that attribute.
If the original object includes references, then references are added to
connected each attribute's appearances to its lookup. If several relations
could be a lookup for the attribute, then add_lookup fails due to the
desired result being ambiguous.
an object of the same class as x.
db <- autodb(ChickWeight)
db
add_lookup(db, "Time")
add_lookup(db, "Chick") # Chick is already a key, so this does nothing
# data objects round numeric and complex values before checking given values
add_lookup(db, "weight", digits = 3)
## Not run: add_lookup(c(db, db), "Chick") # fails: two lookup candidates
# two lookups without references is fine
rels <- subrelations(db)
add_lookup(c(rels, rels), "Chick")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.