I convert the data frame to graph using igraph. when I want to set vertex attribute I get a warning and my vertex does not fit correctly to node. Can any one help me please? The problem also shows when I want to set degree as a node attribute and I would end up to a not correct result (NOT correctly set node degree as node attribute -R). How can I solve the warning?
sample of data that I am using:
https://www.dropbox.com/s/m1ysau37orv1vle/test.csv?dl=0
df = read.csv(".../test.csv") # read csv file
graph <- graph_from_data_frame(df %>% select("id","parent"),directed=F)
summary(graph)
graph <- graph%>%set_vertex_attr("screen_name", value = df$user.screen_name)
graph <- graph%>%set_vertex_attr("id", value = df$id)
graph <- graph%>%set_vertex_attr("parent", value = df$parent)
degrees <- igraph::degree(graph)
degree<-sort(degrees, decreasing = FALSE)
dat<- as.data.frame(degree)
set_vertex_attr(
graph,
name = "degrees",
value = igraph::degree(graph)
)
max_degree_nodes <-10
E(graph)$screen_name[degrees %in% max_degree_nodes]
The Warning:
> graph <- graph%>%set_vertex_attr("screen_name", value = df$user.screen_name)
Warning message:
In vattrs[[name]][index] <- value :
number of items to replace is not a multiple of replacement length