我不知道为什么我不能再将以前工作的 R 脚本用于 igraph。如果您能帮我解决这个问题,我将不胜感激。我在这里使用的脚本是:
图书馆(igraph)
矩阵1<-as.matrix(数据)
矩阵1
var1 var2 var3 var4 var5 var6 var7 var8
[1,] 1.00 0.04 0.21 0.39 0.06 0.37 0.03 0.44
[2,] 0.04 1.00 0.34 0.36 0.63 0.25 0.66 0.18
[3,] 0.21 0.34 1.00 0.44 0.41 0.57 0.72 0.62
[4,] 0.39 0.36 0.44 1.00 0.28 0.14 0.51 0.10
[5,] 0.06 0.63 0.41 0.28 1.00 0.50 0.73 0.39
[6,] 0.37 0.25 0.57 0.14 0.50 1.00 0.50 0.65
[7,] 0.03 0.66 0.72 0.51 0.73 0.50 1.00 0.52
[8,] 0.44 0.18 0.62 0.10 0.39 0.65 0.50 1.00
graph.adjacency(matrix1,mode='undirected',weighted=TRUE)
“然后我在下面收到错误消息”
d[i, ] 中的错误:维数不正确警告:'.Call' 中的堆栈不平衡,51 然后 50
更多信息如下:
> str(matrix1)
num [1:8, 1:8] 1 0.04 0.21 0.39 0.06 0.37 0.03 0.44 0.04 1 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:8] "var1" "var2" "var3" "var4" ...
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] igraph_0.6.5-2
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 dichromat_2.0-0 digest_0.6.3 ggplot2_0.9.3.1
[5] grid_3.0.2 gtable_0.1.2 labeling_0.2 lattice_0.20-23
[9] MASS_7.3-29 Matrix_1.0-14 mgcv_1.7-26 munsell_0.4.2
[13] nlme_3.1-111 plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5
[17] reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_3.0.2
> traceback()
4: c(list(), list(logical(0)))
3: .Call("R_igraph_weighted_adjacency", adjmatrix, as.numeric(mode),
weighted, diag, PACKAGE = "igraph")
2: graph.adjacency.dense(adjmatrix, mode = mode, weighted = weighted,
diag = diag)
1: graph.adjacency(matrix1, mode = "undirected", weighted = TRUE)
谢谢!