Pop out taxa, that is, drop them

pop(.data, ...)

Arguments

.data

Input, object of class Hierarchy, or hierarchies

...

quoted rank names (e.g., family) via ranks(), taxon names (e.g., Poa annua) via nms(), or taxonomic IDs (e.g., 93036) via ids(). You can't pass in arbitrary strings or numbers.

Value

an object of the same class as passed in

Details

supports Hierarchy and hierarchies objects

See also

See filtering-helpers, including for more explanation of how this function works.

Examples

# With Hierarchy class object ex_hierarchy1
#> <Hierarchy> #> no. taxon's: 3 #> Poaceae / family / 4479 #> Poa / genus / 4544 #> Poa annua / species / 93036
## ranks pop(ex_hierarchy1, ranks("family"))
#> <Hierarchy> #> no. taxon's: 2 #> Poa / genus / 4544 #> Poa annua / species / 93036
ex_hierarchy1 %>% pop(ranks("family"))
#> <Hierarchy> #> no. taxon's: 2 #> Poa / genus / 4544 #> Poa annua / species / 93036
ex_hierarchy1 %>% pop(ranks("family", "genus"))
#> <Hierarchy> #> no. taxon's: 1 #> Poa annua / species / 93036
## taxon names ex_hierarchy1 %>% pop(nms("Poa"))
#> <Hierarchy> #> no. taxon's: 2 #> Poaceae / family / 4479 #> Poa annua / species / 93036
ex_hierarchy1 %>% pop(nms("Poaceae", "Poa"))
#> <Hierarchy> #> no. taxon's: 1 #> Poa annua / species / 93036
## taxon ids ex_hierarchy1 %>% pop(ids(4479))
#> <Hierarchy> #> no. taxon's: 2 #> Poa / genus / 4544 #> Poa annua / species / 93036
ex_hierarchy1 %>% pop(ids(4479, 4544))
#> <Hierarchy> #> no. taxon's: 1 #> Poa annua / species / 93036
## mixed: ids and names ex_hierarchy1 %>% pop(ranks("family"), ids(4544))
#> <Hierarchy> #> no. taxon's: 1 #> Poa annua / species / 93036
# With hierarchies class object # single taxonomic group invisible(lapply(ex_hierarchies, print))
#> <Hierarchy> #> no. taxon's: 3 #> Poaceae / family / 4479 #> Poa / genus / 4544 #> Poa annua / species / 93036 #> <Hierarchy> #> no. taxon's: 3 #> Felidae / family / 9681 #> Puma / genus / 146712 #> Puma concolor / species / 9696 #> <Hierarchy> #> no. taxon's: 6 #> Chordata / phylum / 158852 #> Vertebrata / subphylum / 331030 #> Teleostei / class / 161105 #> Salmonidae / family / 161931 #> Salmo / genus / 161994 #> Salmo salar / species / 161996
ex_hierarchies %>% pop(ranks("family")) %>% lapply(., print) %>% invisible
#> <Hierarchy> #> no. taxon's: 2 #> Poa / genus / 4544 #> Poa annua / species / 93036 #> <Hierarchy> #> no. taxon's: 2 #> Puma / genus / 146712 #> Puma concolor / species / 9696 #> <Hierarchy> #> no. taxon's: 5 #> Chordata / phylum / 158852 #> Vertebrata / subphylum / 331030 #> Teleostei / class / 161105 #> Salmo / genus / 161994 #> Salmo salar / species / 161996
## more than one taxonomic group invisible(lapply(ex_hierarchies, print))
#> <Hierarchy> #> no. taxon's: 3 #> Poaceae / family / 4479 #> Poa / genus / 4544 #> Poa annua / species / 93036 #> <Hierarchy> #> no. taxon's: 3 #> Felidae / family / 9681 #> Puma / genus / 146712 #> Puma concolor / species / 9696 #> <Hierarchy> #> no. taxon's: 6 #> Chordata / phylum / 158852 #> Vertebrata / subphylum / 331030 #> Teleostei / class / 161105 #> Salmonidae / family / 161931 #> Salmo / genus / 161994 #> Salmo salar / species / 161996
ex_hierarchies %>% pop(ranks("family", "genus")) %>% lapply(., print) %>% invisible
#> <Hierarchy> #> no. taxon's: 1 #> Poa annua / species / 93036 #> <Hierarchy> #> no. taxon's: 1 #> Puma concolor / species / 9696 #> <Hierarchy> #> no. taxon's: 4 #> Chordata / phylum / 158852 #> Vertebrata / subphylum / 331030 #> Teleostei / class / 161105 #> Salmo salar / species / 161996