我的时间网络数据子集如下:
edge <- data.frame(onset = c(1968, 1968, 2007),
terminus = c(1968, 1968, 2007),
id_from = c(1, 1, 2),
id_to = c(3, 2, 4),
weight = c(1, 3, 2))
vert <- data.frame(onset = c(1968, 1968, 1980, 1978),
terminus = c(2017, 2017, 2017, 2017),
vertex_id = c(1, 2, 3, 4),
abb.name = c("UK", "US", "Germany", "Pakistan"))
# Create networkDynamic object
netd <- networkDynamic(vertex.spells = vert[,c(1,2,3,4)],
edge.spells = edge[,c(1,2,3,4,5)],
create.TEAs = TRUE,
edge.TEA.names = "weight")
vert$abb.name <- as.character(vert$abb.name)
# Set vertex attributes
set.vertex.attribute(netd, "abb.name", as.vector(vert$abb.name))
network.vertex.names(netd)<-vert$abb.name
# Collapse network to look at 1968 network
net68 <- network.collapse(netd,
at = 1968,
rm.time.info = FALSE,
rule = "latest")
# Get centrality score
degree(net68)
但是,这会返回不考虑权重的中心性分数。
[1] 1 1
我如何确保networkDynamic
考虑到(1)每年的权重很重要,因此它不会将相同两个国家之间的多重联系计算为总网络中的一个边缘,(2)权重被计入中心性分数正确,并且(3)获得degree()
包含国家名称的输出?理想情况下,我想获得从 1968 年到 2017 年网络每个部分中每个国家的中心性分数。