我一直在尝试在 ndtv 中实现动态顶点属性,实际上我设法创建了不同大小的顶点,但经过仔细检查,它们与我认为我指定的值不对应。相反,顶点大小与第一个 ID 具有最大大小的顶点 ID 成正比。我试图通过为每个周期创建一个顶点拼写来控制大小,并为大小参数设置不同的值
steps <- 500
num_agents <- 40
vs <- as.data.frame(cbind(rep(1:num_agents, each = steps + 1), rep(1:(steps + 1), times = num_agents), rep(1:(steps + 1), times = num_agents)))
names(vs) <- c("vertex.id", "onset", "terminus")
vs$dimension <- gather(means, key = "key", value = "value", names(means)[1]:names(means)[ncol(means)])[,2]
导致以下结果,其中 vs 是顶点拼写,es 是边缘拼写
head(vs)
vertex.id onset terminus dimension
1 1 1 1 5.000000
2 1 2 2 2.777778
3 1 3 3 2.040816
4 1 4 4 1.492537
5 1 5 5 1.388889
6 1 6 6 1.315789
head(es[,1:4])
onset terminus head tail
1 2 501 12 24
2 2 501 2 24
3 2 501 38 2
4 2 501 21 2
5 2 501 28 2
6 2 501 11 30
trade.net <- network(links[,3:4], directed = TRUE, matrix.type = "edgelist", loops = FALSE, multiple = FALSE, ignore.eval = FALSE)
net.dyn <- networkDynamic(base.net = trade.net, edge.spells = es[,1:4], vertex.spells = vs[,c(2,3,1,4)], create.TEAs = TRUE, vertex.TEA.names = "dimension")
net.dyn <- compute.animation(net.dyn, animation.mode = "kamadakawai",
slice.par=list(start = 1, end = 10, interval=1,
aggregate.dur=1, rule='any'))
render.d3movie(net.dyn, usearrows = TRUE,
displaylabels = F,
bg="#111111",
vertex.border="#dddddd",
vertex.cex = net.dyn %v% 'dimension.active',
edge.col = '#55555599',
render.par=list(tween.frames = 10, show.time = FALSE),
slice.par=list(start = 1 , end = 10, interval = 1, aggregate.dur = 1, rule='any'))
我只渲染了部分数据(501 个周期中的前 10 个),但属性不仅与我想要的不匹配,而且它们在时间上也是不变的。