如何创建距离直方图 table
How to create a histogram of a distance table
我目前正在使用 igraph
软件包并进行我的第一次网络分析。我有一个定向数据集:
m=matrix(nrow=3,ncol=3)
m[1,1]=0
m[1,2]=1
m[1,3]=1
m[2,1]=1
m[2,2]=0
m[2,3]=0
m[3,1]=0
m[3,2]=1
m[3,3]=0
我创建了列表'objects.'
object <- graph.adjacency(m,mode="directed")
我一直在使用各种 distances
函数并找到了 distance_table
函数。 R 将函数记录为:
distance_table
calculates a histogram, by calculating the shortest path length between each pair of vertices. For directed graphs both directions are considered, so every pair of vertices appears twice in the histogram.
我将距离 table 分配给 dt:
dt <- distance_table(object, directed = TRUE)
但是,我不知道如何绘制直方图。我试过:
hist(dt)
hist(dt[1])
和
plot(dt)
然而,其中 none 有效。我将如何绘制此直方图?
distance_table returns一个列表,检查结构:
str(dt)
# List of 2
# $ res : num [1:2] 4 2
# $ unconnected: num 0
然后绘制相关数据 - "res"
:
barplot(dt$res)
我目前正在使用 igraph
软件包并进行我的第一次网络分析。我有一个定向数据集:
m=matrix(nrow=3,ncol=3)
m[1,1]=0
m[1,2]=1
m[1,3]=1
m[2,1]=1
m[2,2]=0
m[2,3]=0
m[3,1]=0
m[3,2]=1
m[3,3]=0
我创建了列表'objects.'
object <- graph.adjacency(m,mode="directed")
我一直在使用各种 distances
函数并找到了 distance_table
函数。 R 将函数记录为:
distance_table
calculates a histogram, by calculating the shortest path length between each pair of vertices. For directed graphs both directions are considered, so every pair of vertices appears twice in the histogram.
我将距离 table 分配给 dt:
dt <- distance_table(object, directed = TRUE)
但是,我不知道如何绘制直方图。我试过:
hist(dt)
hist(dt[1])
和
plot(dt)
然而,其中 none 有效。我将如何绘制此直方图?
distance_table returns一个列表,检查结构:
str(dt)
# List of 2
# $ res : num [1:2] 4 2
# $ unconnected: num 0
然后绘制相关数据 - "res"
:
barplot(dt$res)