r - Storing the node degrees of a group of networks in an excel sheet
问题描述
I have a code that creates multiple random graphs in R using the igraph package.
set.seed(1)
gs1 <- list()
for (x in seq_len(500L))
{
gs1[[x]] <- sample_bipartite(62, 243, type = "gnm",m = 630, directed = TRUE)
}
I know how to individually retrieve the node degrees of each graph.
degree(gs1[[1]], v = V(gs1[[1]]), mode = c("all", "out", "in", "total"),
+ loops = TRUE, normalized = FALSE)
As you can see, I have created 500 random networks with those values. I would like to store the node degrees of all 500 of these networks in an excel sheet (hopefully 500 columns in a single sheet). How can I do so? Kindly advice.
解决方案
简单地
write.csv(sapply(gs1, degree), file = "degrees.csv")
将完成这项工作。这将是一个 305x500 的表格。
此外,在您的情况下,无需编写loops
等,因为您的参数值是默认值。此外,只mode
考虑一个/第一个值,所以也许你应该再看看以?degree
确定你想要什么样的学位。
推荐阅读
- windows - 在 uwp 应用程序中取消配对双模蓝牙设备
- c - 在 C 程序中用 Inline asm 编写的算术函数导致分段错误
- android - React Native 图标和 gif 有时看不到 android sdk 19 及更低版本
- ruby-on-rails - ERB 没有正确解释变量
- string - 在脚本中添加对希腊语字符的支持时需要帮助
- java - 在将原语添加到集合中更快的自动装箱或显式转换是什么?
- javascript - 可以通过浏览器和 websocket 连接到 azure 事件中心吗?
- javascript - 合并函数和抽象(JavaScript)请帮助
- akka - 将存储在表中的工作分配给多个进程
- c# - 无法删除 C# 中 json 字符串中的斜杠“\”