hierarchy: The Hierarchy class

Description Usage Arguments Details Value See Also Examples

View source: R/hierarchy.R

Description

A class containing an ordered list of taxon() objects that represent a hierarchical classification.

Usage

1

Arguments

...

Any number of object of class Taxon or taxonomic names as character strings

.list

An alternate to the ... input. Any number of object of class taxon() or character vectors in a list. Cannot be used with ....

Details

On initialization, taxa are sorted if they have ranks with a known order.

Methods

pop(rank_names)

Remove Taxon elements by rank name, taxon name or taxon ID. The change happens in place, so you don't need to assign output to a new object. returns self - rank_names (character) a vector of rank names

pick(rank_names)

Select Taxon elements by rank name, taxon name or taxon ID. The change happens in place, so you don't need to assign output to a new object. returns self - rank_names (character) a vector of rank names

Value

An R6Class object of class Hierarchy

See Also

Other classes: hierarchies, taxa, taxmap, taxon_database, taxon_id, taxon_name, taxon_rank, taxonomy, taxon

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(x <- taxon(
  name = taxon_name("Poaceae"),
  rank = taxon_rank("family"),
  id = taxon_id(4479)
))

(y <- taxon(
  name = taxon_name("Poa"),
  rank = taxon_rank("genus"),
  id = taxon_id(4544)
))

(z <- taxon(
  name = taxon_name("Poa annua"),
  rank = taxon_rank("species"),
  id = taxon_id(93036)
))

(res <- hierarchy(z, y, x))

res$taxa
res$ranklist

# pop off a rank
pop(res, ranks("family"))

# pick a rank
(res <- hierarchy(z, y, x))
pick(res, ranks("family"))


# null taxa
x <- taxon(NULL)
(res <- hierarchy(x, x, x))
## similar to hierarchy(), but `taxa` slot is not empty

taxa documentation built on Aug. 10, 2018, 1:12 a.m.