问题
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