Last active
August 29, 2015 14:20
-
-
Save jhpoelen/d683c7a35da50956e8b0 to your computer and use it in GitHub Desktop.
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
#install rglobi (see ropensci.org for more info) | |
install.packages(c('rglobi')) | |
# read species list after exporting as csv | |
krak <- read.csv(file='Krak_list_DELETE.csv', stringsAsFactors=F) | |
# pick unique families | |
taxonList <- unique(krak$Family) | |
# find and aggregate interactions for each species . . . one by one | |
interactions <- Reduce(function(accum, taxon) { | |
message(paste(nrow(accum), '.', sep=''), appendLF=F) | |
rbind(accum, rglobi::get_interactions_by_taxa(taxon, interactiontype='interactsWith', returnobservations=T)) | |
}, | |
taxonList, | |
init=data.frame()) | |
# write interactions to file | |
write.csv(interactions, file='interactions.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment