我有一个数据集如下:
set.seed(123)
A = data.frame(rnorm(10),rnorm(10),rnorm(10),rnorm(10))
然后使用 igraph 包从以下内容中制作网络:
inv<-cor(t(A))
inv[inv<0.5] <- 0
inv[inv==1] <- 0
g1 <- graph.adjacency(inv, mode = "undirected", diag=FALSE, weighted=TRUE)
现在计算g1的配比系数,
assortativity (g1, types1, types2 = NULL, directed = TRUE)
我现在的问题是,我应该如何设置“类型”,它在文档中说,它是顶点值。这究竟是什么意思?我想计算网络中任何 5 个顶点的分类性。谁能告诉我这是怎么做的?
最佳答案
所以我猜你想要分类的名义版本。例如。
V(g1)$foo <- sample(1:3, replace=TRUE, vcount(g1))
assortativity.nominal(g1, types=V(g1)$foo)
# [1] -0.2270916
类型必须是从 1 开始的整数。请参阅文档中的详细信息。
关于r - 计算 igraph 中的分类性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21727813/