私は対称距離行列(x)を持っています:
0 2.6096 2.3601 5.6109
2.6096 0 1.7045 6.8441
2.3601 1.7045 0 6.5946
5.6109 6.8441 6.5946 0
スペクトル密度を計算するために、グラフとして分析したいと思います。そのためには、次の手順に従います (igraph を使用):
x_mat <- as.matrix(x,matrix.type="adjacency") #get adjacency matrix`
x_graph <- graph.adjacency(x_mat) #convert to graph
x_lap <- graph.laplacian(x_graph) #convert to laplacian graph
x_eig <- eigen(x_lap,symmetric=TRUE,only.values=TRUE)
(I'm not sure how to plot the spectral density, but I'm not even there yet)
しかし、最初から問題があります。マトリックスをマトリックスにすることができます
x_mat <- as.matrix(x,matrix.type="adjacency")
is.matrix(x_mat)
[1] TRUE
x_mat
[,1]
[1,] Numeric,39204
しかし、強制的に数値にすることはできません
mode(x_mat) <- "numeric"
_Error in eval(expr, envir, enclos) :
(list) object cannot be coerced to type 'double'_
パイプラインに沿って移動するには、隣接行列を数値にする必要があります。何かアドバイス?もちろん、私の目標を達成するための代替方法も大歓迎です。
前もって感謝します。