数值属性在ggnet2中按字母顺序排序 [英] Numeric attributes are being alpha-sorted in ggnet2

查看:68
本文介绍了数值属性在ggnet2中按字母顺序排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用ggnet2构建了依赖关系图,并试图基于Cost(在节点数据结构中是数字属性)设置顶点的大小.

I've built a dependency graph using ggnet2 and am trying to set the size of the vertex based on Cost, which is a numeric attribute in the node data structure.

问题在于调用方法 set.vertex.attribute .

x = data.frame(ID = network.vertex.names(deps))
for (i in names(df)) {
  y = merge(x, df, by = "ID", sort = F)[,i]
  set.vertex.attribute(deps, i, as.character(y))
}

如果我传递一个整数,它将抱怨set.vertex.attribute 中给出的不适当的值.在此处

If I passing an integer, it complains that Inappropriate value given in set.vertex.attribute. A similar issue was reported here

推荐答案

如果我删除循环并为整个vector添加属性,那么一切都很好.

If I remove the loop and add the attribute for the whole vector, all is well.

set.vertex.attribute(deps, "Cost", df$Cost)

这篇关于数值属性在ggnet2中按字母顺序排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆