pop: Pop names out

View source: R/pop.R

popR Documentation

Pop names out

Description

That is, drop them

Usage

pop(.data, ...)

Arguments

.data

Input, object of class taxon

...

Further unnamed args, see examples

Value

For taxon inputs gives back a taxon object. For taxa inputs gives back a taxa object. For taxondf inputs, gives back a taxondf object.

Examples

# operating on `taxon` objects
out <- make_taxon(genus="Poa", epithet="annua", authority="L.",
   family='Poaceae', clazz='Poales', kingdom='Plantae', variety='annua')
## single taxonomic group
out %>% pop(family)
out %>% pop(genus)
out %>% pop(species)
## many taxonomic groups
out %>% pop(family, genus, species)

# operating on taxonomic data.frames
df <- data.frame(class=c('Magnoliopsida','Magnoliopsida','Magnoliopsida',
                         'Magnoliopsida','Magnoliopsida','Magnoliopsida'),
         order=c('Asterales','Asterales','Fagales','Poales','Poales','Poales'),
         family=c('Asteraceae','Asteraceae','Fagaceae','Poaceae','Poaceae','Poaceae'),
         genus=c('Helianthus','Helianthus','Quercus','Poa','Festuca','Holodiscus'),
         stringsAsFactors = FALSE)
(df2 <- taxon_df(df))

## pop out a single taxonomic group
df2 %>% pop(order)
df2 %>% pop(family)
df2 %>% pop(genus)

## pop out many taxonomic groups
df2 %>% pop(order, family)
df2 %>% pop(order, genus)

# From taxa object
df2 %>% scatter %>% pop(family)
df2 %>% scatter %>% pop(family, species)
df2 %>% scatter %>% pop(family, species, genus)

ropensci/binomen documentation built on May 18, 2022, 9:47 a.m.