Created
October 13, 2013 05:30
-
-
Save johnbaums/6958504 to your computer and use it in GitHub Desktop.
List plant families indexed by theplantlist.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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