Pick out specific taxa, while others are dropped

pick(.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

# ranks ex_hierarchy1
#> <Hierarchy> #> no. taxon's: 3 #> Poaceae / family / 4479 #> Poa / genus / 4544 #> Poa annua / species / 93036
ex_hierarchy1 %>% pick(ranks("family"))
#> <Hierarchy> #> no. taxon's: 1 #> Poaceae / family / 4479
ex_hierarchy1 %>% pick(ranks("family", "genus"))
#> <Hierarchy> #> no. taxon's: 2 #> Poaceae / family / 4479 #> Poa / genus / 4544
# taxon names ex_hierarchy1 %>% pick(nms('Poa'))
#> <Hierarchy> #> no. taxon's: 1 #> Poa / genus / 4544
ex_hierarchy1 %>% pick(nms("Poaceae", "Poa"))
#> <Hierarchy> #> no. taxon's: 2 #> Poaceae / family / 4479 #> Poa / genus / 4544
# taxon ids ex_hierarchy1 %>% pick(ids(4479))
#> <Hierarchy> #> no. taxon's: 1 #> Poaceae / family / 4479
ex_hierarchy1 %>% pick(ids(4479, 4544))
#> <Hierarchy> #> no. taxon's: 2 #> Poaceae / family / 4479 #> Poa / genus / 4544
# mixed: ids and names ex_hierarchy1 %>% pick(ranks("family"), ids(4544))
#> <Hierarchy> #> no. taxon's: 2 #> Poaceae / family / 4479 #> Poa / genus / 4544
## single taxonomic group ex_hierarchy1 %>% pick(ranks("family"))
#> <Hierarchy> #> no. taxon's: 1 #> Poaceae / family / 4479
pick(ex_hierarchy1, ranks("family"))
#> <Hierarchy> #> no. taxon's: 1 #> Poaceae / family / 4479
### more than 1 - remake res object above first ex_hierarchy1 %>% pick(ranks("family", "genus"))
#> <Hierarchy> #> no. taxon's: 2 #> Poaceae / family / 4479 #> Poa / genus / 4544
# hierarchies # 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 %>% pick(ranks("family")) %>% lapply(., print) %>% invisible
#> <Hierarchy> #> no. taxon's: 1 #> Poaceae / family / 4479 #> <Hierarchy> #> no. taxon's: 1 #> Felidae / family / 9681 #> <Hierarchy> #> no. taxon's: 1 #> Salmonidae / family / 161931
## 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 %>% pick(ranks("family", "genus")) %>% lapply(., print) %>% invisible
#> <Hierarchy> #> no. taxon's: 2 #> Poaceae / family / 4479 #> Poa / genus / 4544 #> <Hierarchy> #> no. taxon's: 2 #> Felidae / family / 9681 #> Puma / genus / 146712 #> <Hierarchy> #> no. taxon's: 2 #> Salmonidae / family / 161931 #> Salmo / genus / 161994