Skip to content

Instantly share code, notes, and snippets.

@sckott
Last active October 13, 2015 20:38
Show Gist options
  • Save sckott/4252995 to your computer and use it in GitHub Desktop.
Save sckott/4252995 to your computer and use it in GitHub Desktop.
How to get fish names downstream from family names using taxize
# How to get fish names downstream from family names using taxize
## load libraries
install.packages(c("plyr","taxize"))
library(taxize); library(plyr)
## get taxonomic serial numbers from ITIS for these two fish families
tsns <- get_colid(c("Anostomidae","Curimatidae"))
## Use the function `downstream` to get all species (specified by the `downto` argument) in these two families
out <- downstream(tsns, downto="Species")
## Use ldply from plyr pkg to put the two data.frame's together in one data.frame
namesoutdf <- ldply(out)
## Take a peak
head(namesoutdf)
tsn parentName parentTsn taxonName rankId rankName
1 163155 Chilodus 163154 Chilodus punctatus 220 Species
2 163162 Leporinus 163161 Leporinus fasciatus 220 Species
3 163172 Leporinus 163161 Leporinus nigrotaeniatus 220 Species
4 163176 Leporinus 163161 Leporinus striatus 220 Species
5 163179 Abramites 163178 Abramites hypselonotus 220 Species
6 163185 Anostomus 163184 Anostomus anostomus 220 Species
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment