Skip to content

Instantly share code, notes, and snippets.

@hemprichbennett
Last active March 25, 2022 13:31
Show Gist options
  • Save hemprichbennett/e4ec239833cc2f88955d533954bf0abd to your computer and use it in GitHub Desktop.
Save hemprichbennett/e4ec239833cc2f88955d533954bf0abd to your computer and use it in GitHub Desktop.
Quickly calculating network metrics in bipartite
library(bipartite)
# make some example networks
mat_list <- list()
for(i in 1:512){
mat_list[[i]] <- matrix(ncol = 10, nrow = 10,
sample(c(0,1), 100, replace = T))
}
# now do all the calculations at once (depending on your computers ability)
# using lapply
metric_value_list <- lapply(mat_list, function(x)
networklevel(x, index = c('connectance', 'NODF', 'robustness')))
# then bind the list together into a dataframe
metric_value_df <- dplyr::bind_rows(metric_value_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment