Get class(es) in an ontology

get_class(..., regex = FALSE, external = FALSE, ontology = NULL)

Arguments

...

combination of column name and value to filter that column by. The value to filter by can be provided as regular expression, if regex = TRUE.

regex

logical(1)
whether or not the value in ... shall be matched in full, or whether any partial match should be returned.

external

logical(1)
whether or not the external classes (TRUE), or the harmonized classes should be returned (FALSE, default).

ontology

ontology(1)
either a path where the ontology is stored, or an already loaded ontology.

Value

A table of the class(es) in the ontology according to the values in ...

Examples

ontoDir <- system.file("extdata", "crops.rds", package = "ontologics")
onto <- load_ontology(path = ontoDir)

# exact classes from a loaded ontology ...
get_class(label = "class", ontology = onto)
#> # A tibble: 1 × 8
#>   label id     has_broader description        has_close_match has_narrower_match
#>   <chr> <chr>  <chr>       <chr>              <chr>           <chr>             
#> 1 class .xx.xx group       Classes of crop o… NA              NA                
#> # ℹ 2 more variables: has_broader_match <chr>, has_exact_match <chr>

# ... or one stored on the harddisc
get_class(id = ".xx.xx", ontology = ontoDir)
#> # A tibble: 1 × 8
#>   label id     has_broader description        has_close_match has_narrower_match
#>   <chr> <chr>  <chr>       <chr>              <chr>           <chr>             
#> 1 class .xx.xx group       Classes of crop o… NA              NA                
#> # ℹ 2 more variables: has_broader_match <chr>, has_exact_match <chr>

# use regular expressions ...
get_class(label = "ro", regex = TRUE, ontology = onto)
#> # A tibble: 2 × 8
#>   label id        has_broader description     has_close_match has_narrower_match
#>   <chr> <chr>     <chr>       <chr>           <chr>           <chr>             
#> 1 group .xx       NA          Groups of crop… NA              NA                
#> 2 crop  .xx.xx.xx class       Crop or livest… NA              NA                
#> # ℹ 2 more variables: has_broader_match <chr>, has_exact_match <chr>

# get all sources
get_class(ontology = onto)
#> # A tibble: 3 × 8
#>   label id        has_broader description     has_close_match has_narrower_match
#>   <chr> <chr>     <chr>       <chr>           <chr>           <chr>             
#> 1 group .xx       NA          Groups of crop… NA              NA                
#> 2 class .xx.xx    group       Classes of cro… NA              NA                
#> 3 crop  .xx.xx.xx class       Crop or livest… NA              NA                
#> # ℹ 2 more variables: has_broader_match <chr>, has_exact_match <chr>