library("knitr") hook_output <- knitr::knit_hooks$get("output") knitr::knit_hooks$set(output = function(x, options) { lines <- options$output.lines if (is.null(lines)) { return(hook_output(x, options)) # pass to default hook } x <- unlist(strsplit(x, "\n")) more <- "..." if (length(lines)==1) { # first n lines if (length(x) > lines) { # truncate the output, but add .... x <- c(head(x, lines), more) } } else { x <- c(if (abs(lines[1])>1) more else NULL, x[lines], if (length(x)>lines[abs(length(lines))]) more else NULL ) } # paste these lines together x <- paste(c(x, ""), collapse = "\n") hook_output(x, options) }) knitr::opts_chunk$set( comment = "#>", collapse = TRUE, warning = FALSE, message = FALSE )
binomen provides various taxonomic classes for defining a single taxon, multiple taxa, and a taxonomic data.frame
It is sort of a companion to taxize, where you can get taxonomic data on taxonomic names from the web.
The classes (S3):
taxontaxonreftaxonrefsbinomialgrouping (i.e., classification)The verbs:
gethier() - get hierarchy from a taxon classscatter() - make each row in taxonomic data.frame (taxondf) a separate taxon object within a single taxa objectassemble() - make a taxa object into a taxondf data.framepick() - pick out one or more taxonomic groupspop() - pop out (drop) one or more taxonomic groupsspan() - pick a range between two taxonomic groups (inclusive)strain() - filter by taxonomic groups, like dplyr's filtername() - get the taxon name for each taxonref objecturi() - get the reference uri for each taxonref objectrank() - get the taxonomic rank for each taxonref objectid() - get the reference uri for each taxonref objectStable version from CRAN
install.packages("binomen")
Development version from GitHub
install.packages("devtools") devtools::install_github("ropensci/binomen")
library("binomen")
Make a taxon object
(obj <- make_taxon(genus="Poa", epithet="annua", authority="L.", family='Poaceae', clazz='Poales', kingdom='Plantae', variety='annua'))
Index to various parts of the object
The binomial
obj$binomial
The authority
obj$binomial$authority
The classification
obj$grouping
The family
obj$grouping$family
Get one or more ranks via pick()
obj %>% pick(family) obj %>% pick(family, genus)
Drop one or more ranks via pop()
obj %>% pop(family) obj %>% pop(family, genus)
Get a range of ranks via span()
obj %>% span(kingdom, family)
Extract classification as a data.frame
gethier(obj)
Make one
df <- data.frame(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))
Parse - get rank order via pick()
df2 %>% pick(order)
get ranks order, family, and genus via pick()
df2 %>% pick(order, family, genus)
get range of names via span(), from rank X to rank Y
df2 %>% span(family, genus)
Separate each row into a taxon class (many taxon objects are a taxa class)
scatter(df2)
And you can re-assemble a data.frame from the output of scatter() with assemble()
out <- scatter(df2) assemble(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.