terminfo: Terminfo Objects

View source: R/terms.R

terminfoR Documentation

Terminfo Objects

Description

as.terminfo creates an object (or a list of objects) of type "terminfo". The object to be coerced can be a character vector (of term IRIs), or a data.frame. In the latter case, there must be a column "id" with term IRIs. If the object is already of type "terminfo", a new terminfo object will be created so options such as withClassification will be applied.

is.terminfo tests whether an object is of type "terminfo"

is_valid_terminfo tests which of the objects in the list are valid terminfo objects, and returns a logical vector of the same length as x. An object is a valid terminfo object if it is of type "terminfo" and its IRI has been found in the database.

print pretty-prints objects of type "terminfo"

Usage

as.terminfo(
  x,
  withClassification = getOption("rphenoscape.fetch.classification", default = FALSE),
  ...
)

is.terminfo(x)

is_valid_terminfo(x)

## S3 method for class 'terminfo'
print(x, ...)

Arguments

x

an object of type "terminfo" or coercible to it, or to be tested for being of type "terminfo"

withClassification

logical. If TRUE classification data will be available through the terminfo object at key "classification". Default is FALSE, because obtaining taxa requires an additional query per object. The default can be customized by setting the "rphenoscape.fetch.classification" option.

...

additional parameters where applicable

Details

Create and test objects of type "terminfo", and extract properties from them.

Value

as.terminfo returns and object of type "terminfo", or a list of such objects if the object to be coerced had multiple elements (if a vector) or rows (if a data.frame). A terminfo object has properties "id" (ID, i.e., IRI of the term), "label" (label of the term if one exists). If the term is a taxon additional properties will be populated: "extinct", "rank", "common_name". If withClassification is TRUE,there will also be a key "classification" (a list with properties "subClassOf", "equivalentTo" and "superClassOf").

is.terminfo returns TRUE if the object is of type "terminfo" and FALSE otherwise.

is_valid_terminfo returns a logical vector of the same length as the input array of objects, with TRUE for those objects in the list that are of type "terminfo" and correspond to a term in the database.

Examples

# find a term iri
term_iri <- find_term('basihyal bone', matchType='exact')
# turn it into a terminfo object
obj <- as.terminfo(term_iri)
class(obj)
obj

# classification details can be requested:
term_iri <- find_term('maxilla', matchType='exact')
# turn it into a terminfo object
obj <- as.terminfo(term_iri, withClassification=TRUE)
class(obj)
obj

# taxon terms have additional properties: 
term_iri <- find_term('Coralliozetus angelicus', matchType='exact')
# turn it into a terminfo object
obj <- as.terminfo(term_iri)
class(obj)
obj


xu-hong/rphenoscape documentation built on Jan. 28, 2024, 12:22 p.m.