R-顶点属性-'在set.vertex.attribute中给定的不适当的值. [英] R - Vertex attributes - 'Inappropriate value given in set.vertex.attribute.'

查看:493
本文介绍了R-顶点属性-'在set.vertex.attribute中给定的不适当的值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个data.frame,其中包含要用作网络文件中属性的值.

I have a data.frame containing values I want to use as attributes in a network file.

当我尝试手动将值分配为属性时,它们一半有效,但另一半则显示此错误.我仔细查看了数据,但看不到任何内在原因.

When I try to assign the values as attributes manually half of them work but the other half show this error. I have looked closely at the data and I cannot see anything intrinsic that should be causing this.

格式化矢量输入(此功能有效)

Format vector input (this one works)

visitgo2n%v%"hhid" <- attr2$hhid

这是错误:

"Error in set.vertex.attribute(x, attrname = attrname, value = value) : 
  Inappropriate value given in set.vertex.attribute."

我尝试删除空白,但这不起作用.

I have tried removing white space but this does not work.

我也尝试过以这种方式输入向量,但出现相同的错误:

I have also tried entering the vectors in this way but I get the same error:

for (n in names(attr2)) {
  visitgo2n %v% n <- attr2[[n]]
}

什么会导致一半向量不合适",什么值合适?

What could be causing half the vectors to be 'inappropriate', what values are appropriate?

推荐答案

所以这有点晚了,但是直到今天我遇到了同样的问题,并发现这可能是因为变量是一个因素.您需要将其转换为类似这样的字符:

So this is a bit late, but I ran into the same issue just today and figured out that this is probably because the variable is a factor. You need to convert it to a character like so:

attr2$hhid <-  as.character(attr2$hhid)

这应该可以解决问题.

这篇关于R-顶点属性-'在set.vertex.attribute中给定的不适当的值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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