Last active
March 25, 2022 13:31
-
-
Save hemprichbennett/e4ec239833cc2f88955d533954bf0abd to your computer and use it in GitHub Desktop.
Quickly calculating network metrics in bipartite
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
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