Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 557
Tom Davidson Avatar asked Feb 18 '15 02:02

Tom Davidson


1 Answers

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.

like image 107
ibakecookies Avatar answered Oct 06 '22 11:10

ibakecookies