Skip to content

Instantly share code, notes, and snippets.

@johnbaums
Created October 13, 2013 05:30
Show Gist options
  • Save johnbaums/6958504 to your computer and use it in GitHub Desktop.
Save johnbaums/6958504 to your computer and use it in GitHub Desktop.
List plant families indexed by theplantlist.org
tpl_families <- function () {
require(RCurl)
require(XML)
temp <- getURL('http://www.theplantlist.org/browse/-/')
temp <- htmlParse(temp)
families <- xpathSApply(temp, "//ul[@id='nametree']//a", xmlValue)
groups <- factor(basename(dirname(xpathSApply(temp,
"//ul[@id='nametree']//a",
xmlGetAttr, 'href'))),
levels=c('A', 'B', 'G', 'P'),
labels=c('Angiosperms', 'Bryophytes',
'Gymnosperms', 'Pteridophytes'))
data.frame(group=groups, family=families)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment