Package 'Binomen'
Total Page:16
File Type:pdf, Size:1020Kb
Package ‘binomen’ April 26, 2017 Title 'Taxonomic' Specification and Parsing Methods Description Includes functions for working with taxonomic data, including functions for combining, separating, and filtering taxonomic groups by any rank or name. Allows standard ('SE') and non-standard evaluation ('NSE'). Version 0.1.2 License MIT + file LICENSE URL https://github.com/ropensci/binomen BugReports https://github.com/ropensci/binomen/issues LazyLoad yes LazyData yes VignetteBuilder knitr Imports methods, stats, jsonlite, lazyeval, dplyr Suggests roxygen2 (>= 6.0.1), testthat, knitr, taxize, covr RoxygenNote 6.0.1 NeedsCompilation no Author Scott Chamberlain [aut, cre] Maintainer Scott Chamberlain <[email protected]> Repository CRAN Date/Publication 2017-04-25 22:11:47 UTC R topics documented: binomen-package . .2 binomial . .3 gethier . .3 grouping . .4 make_taxon . .6 make_taxon_fromclass . .7 parts . .7 1 2 binomen-package pick .............................................9 pop ............................................. 10 rank_table . 11 scatter . 11 span............................................. 12 strain . 13 taxa ............................................. 14 taxon . 14 taxonref . 15 taxonrefs . 16 taxon_classes . 16 taxon_df . 17 Index 18 binomen-package Taxonomic class specification and parsing methods Description Taxonomic class specification and parsing methods Author(s) Scott Chamberlain <[email protected]> Examples library("binomen") # operating on `taxon` objects out <- make_taxon(genus="Poa", epithet="annua", authority="L.", family='Poaceae', clazz='Poales', kingdom='Plantae', variety='annua') # get single name out %>% pick(family) out %>% pick(genus) out %>% pick(species) out %>% pick(species) %>% name() out %>% pick(species) %>% uri() # get range of names out %>% span(kingdom, genus) # 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)) binomial 3 ## select single taxonomic class df2 %>% pick(order) df2 %>% pick(family, genus) ## filter to get a range of classes df2 %>% span(order, genus) df2 %>% span(family, genus) binomial A class to represent a taxonomic binomial Description A class to represent a taxonomic binomial Usage binomial(genus = NULL, epithet = NULL, canonical = NULL, species = NULL, authority = NULL) Arguments genus A genus name epithet A specific epithet name canonical Canonical name species Species, genus plus epithet authority Authority name Examples binomial("Poa") binomial("Poa", "annua", authority="L.") gethier Get hierarchy as a data.frame Description Get hierarchy as a data.frame Usage gethier(x) 4 grouping Arguments x An object of class taxon Examples bin <- binomial("Poa", "annua", authority="L.") class <- grouping(kingdom=taxonref("kingdom", "Plantae"), species=taxonref("family", "Poaceae")) out <- taxon(bin, class) # get hierarchy as data.frame gethier(out) grouping A class to represent a taxonomic classification Description A class to represent a taxonomic classification Usage grouping(kingdom = NULL, subkingdom = NULL, infrakingdom = NULL, division = NULL, phylum = NULL, subdivision = NULL, infradavision = NULL, superclass = NULL, clazz = NULL, subclass = NULL, infraclass = NULL, superorder = NULL, order = NULL, suborder = NULL, infraorder = NULL, superfamily = NULL, family = NULL, subfamily = NULL, tribe = NULL, subtribe = NULL, genus = NULL, subgenus = NULL, section = NULL, subsection = NULL, species = NULL, subspecies = NULL, variety = NULL, race = NULL, subvariety = NULL, stirp = NULL, morph = NULL, form = NULL, aberration = NULL, subform = NULL, unspecified = NULL) Arguments kingdom A kingdom name subkingdom A subkingdom name infrakingdom A infrakingdom name division A division name phylum A phylum name subdivision A subdivision name infradavision A infradavision name superclass A superclass name clazz A clazz name subclass A subclass name grouping 5 infraclass A infraclass name superorder A superorder name order A order name suborder A suborder name infraorder A infraorder name superfamily A superfamily name family A family name subfamily A subfamily name tribe A tribe name subtribe A subtribe name genus A genus name subgenus A subgenus name section A section name subsection A subsection name species A species name subspecies A subspecies name variety A variety name race A race name subvariety A subvariety name stirp A stirp name morph A morph name form A form name aberration A aberration name subform A subform name unspecified A unspecified name Examples grouping(kingdom=taxonref("kingdom", "Animalia"), species=taxonref("species", "Homo sapiens")) 6 make_taxon make_taxon Make taxon from class Description Make taxon from class Usage make_taxon(genus = "none", epithet = "none", authority = "none", ...) Arguments genus Genus name, e.g., Homo (in Homo sapiens) epithet Specific epithet, e.g., sapiens (in Homo sapiens) authority Taxonomic authority ... Further args. Examples (out <- make_taxon(genus="Poa")) (out <- make_taxon(genus="Poa", epithet="annua", authority="L.")) (out <- make_taxon(genus="Poa", epithet="annua", authority="L.", family='Poaceae', clazz='Poales', kingdom='Plantae', variety='annua')) out$binomial out$binomial$canonical out$binomial$species out$binomial$authority out$grouping out$grouping$family out %>% pick(family) # get a single rank out %>% span(kingdom, family) # get a range of ranks gethier(out) # get hierarchy as data.frame # Using dplyr 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'), species=c('annuus','petrus','kellog','annua','arundinaceae','fava'), stringsAsFactors = FALSE) library(dplyr) xx <- df %>% rowwise() xx %>% do(i = strain(make_taxon(.$species, genus = .$genus), . < family)) %>% .[[1]] xx %>% do(i = strain(make_taxon(.$species, genus = .$genus), . < genus)) %>% .[[1]] xx %>% do(i = strain(make_taxon(.$species, genus = .$genus), . < species)) %>% .[[1]] make_taxon_fromclass 7 make_taxon_fromclass Make taxon from class Description Make taxon from class Usage make_taxon_fromclass(data, authority = "none") Arguments data A data.frame authority Taxonomic authority Examples df <- data.frame(rank=c('family','tribe','subtribe','genus','subgenus','species'), name=c('Helianthi','Helianthi','Helianthi','Poa','Festuci','Poa annua'), id=c(1,2,3,4,5,6), stringsAsFactors = FALSE) apply(df, 1, make_taxon_fromclass) parts Pick out parts by name Description This suite of functions act on taxon or taxonref objects, and pick out object elements by the name of the function. Usage name(x, unname = TRUE) ## S3 method for class 'taxon' name(x, unname = TRUE) ## S3 method for class 'taxonref' name(x, unname = TRUE) uri(x, unname = TRUE) ## S3 method for class 'taxon' uri(x, unname = TRUE) 8 parts ## S3 method for class 'taxonref' uri(x, unname = TRUE) rank(x, unname = TRUE) ## S3 method for class 'taxon' rank(x, unname = TRUE) ## S3 method for class 'taxonref' rank(x, unname = TRUE) taxonid(x, unname = TRUE) ## S3 method for class 'taxon' taxonid(x, unname = TRUE) ## S3 method for class 'taxonref' taxonid(x, unname = TRUE) Arguments x Input, object of class taxon or taxonref unname (logical) Unname output elements? Ignored when input is of class taxonref. Default: TRUE Value For taxon inputs, gives back a taxonref object. For taxondf inputs, gives back taxondf. Examples # operating on `taxon` objects out <- make_taxon(genus="Poa", epithet="annua", authority="L.", family='Poaceae', clazz='Poales', kingdom='Plantae', variety='annua') out %>% name() out %>% uri() out %>% rank() out %>% taxonid() ## or don't unname the output out %>% name(unname = FALSE) # operating on `taxonref` objects res <- taxonref("genus", "Poa", 56, "http://scottchamberlain.info/") res %>% name() res %>% uri() res %>% rank() res %>% taxonid() pick 9 pick Pick names Description Pick names Usage pick(.data, ...) Arguments .data Input, object of class taxon ... Further unnamed args, see examples Value For taxon inputs, gives back a taxonref object. For taxondf inputs, gives back taxondf. Examples # operating on `taxon` objects out <- make_taxon(genus="Poa", epithet="annua", authority="L.", family='Poaceae', clazz='Poales', kingdom='Plantae', variety='annua') out %>% pick(family) out %>% pick(genus) out %>% pick(species, genus) out %>% pick(species) %>% name() out %>% pick(species) %>% uri() # 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)) ## select single or many taxonomic classes df2 %>% pick(order) df2 %>% pick(family, genus) # From taxa object df2 %>% scatter %>% pick(family) df2 %>% scatter %>% pick(family, species) df2 %>% scatter %>% pick(family,