R - Vertex attributes - 'Inappropriate value given in set.vertex.attribute.'

牧云@^-^@ 提交于 2019-12-24 10:54:15

问题


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

Here is the error:

"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?


回答1:


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)

This should fix the issue.



来源:https://stackoverflow.com/questions/28574757/r-vertex-attributes-inappropriate-value-given-in-set-vertex-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!