Skip to content

Instantly share code, notes, and snippets.

@jhpoelen
Last active August 29, 2015 14:20
Show Gist options
  • Save jhpoelen/d683c7a35da50956e8b0 to your computer and use it in GitHub Desktop.
Save jhpoelen/d683c7a35da50956e8b0 to your computer and use it in GitHub Desktop.
#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