Skip to content

Commit

Permalink
excluding hybrids from species count
Browse files Browse the repository at this point in the history
  • Loading branch information
wcornwell committed May 2, 2015
1 parent f08412a commit ce474a6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: TaxonLookup
Title: What the package does (one line)
Version: 0.1.1
Version: 0.1.2
Description: What the package does (one paragraph)
Depends: R (>= 3.1.0)
License: BSD_2_clause + file LICENSE
Expand Down
2 changes: 1 addition & 1 deletion R/plant_lookup.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plant_lookup <- function(version=plant_lookup_version_current()) {
##' @param all test against all version known to the package?
plant_lookup_versions <- function(all=FALSE) {
if (all) {
c("0.1.0", "0.1.1")
c("0.1.0", "0.1.1","0.1.2")
} else {
re <- "^plant_lookup_(.+).csv$"
sub(re, "\\1", dir(plant_lookup_path(), re))
Expand Down
21 changes: 18 additions & 3 deletions createlookup.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,27 @@ downloadPlantList<-function(familyList){
get.genera<-function(family, path,tf){
ah <- read.csv(file.path(path,family), stringsAsFactors=FALSE)
accepted.species<-subset(ah,Taxonomic.status.in.TPL=="Accepted")
if(nrow(accepted.species)==0) return(NULL)
group<-tf$group[match(accepted.species$Family[1],tf$family)]

if (nrow(accepted.species)==0) {
return(NULL)
}

not.species <- c("Species.hybrid.marker", "Genus.hybrid.marker", "Infraspecific.epithet")
tmp <- accepted.species[not.species]
accepted.species <- accepted.species[apply(tmp == "" | is.na(tmp), 1, all), ]

if (nrow(accepted.species)==0) {
return(NULL)
}

# not using table(accepted.species$Genus) because it leaves things oddly structured
n.species <- tapply(accepted.species$Infraspecific.rank, accepted.species$Genus, length)

out <- data.frame(family=accepted.species$Family[1],
genus=unique(accepted.species$Genus),
genus=names(n.species),
group=group,
number.of.species=tapply(accepted.species$Infraspecific.rank, accepted.species$Genus,FUN=function(x)sum(is.na(x)|x=="")),
number.of.species=n.species,
stringsAsFactors=FALSE)
return(out)
}
Expand Down

0 comments on commit ce474a6

Please sign in to comment.