0

我使用 igraph 将数据框转换为图形。当我想设置顶点属性时,我收到一个警告,并且我的顶点不适合节点。任何人都可以帮助我吗?该问题还表明,当我想将度设置为节点属性时,我最终会得到不正确的结果(未正确将节点度设置为节点属性 -R)。我该如何解决警告?

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]

警告:

> 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

4

0 回答 0