我使用rstudio版本0.99.879和包igraph版本1.0.1。我的問題與此問題密切相關:igraph package in RStudio: Bipartite graph projection error
但是,我的問題更多地涉及到數據結構。下面是我用csv.file的一個例子的鏈接:https://workupload.com/file/6qhyZqc和下面的代碼:二分圖投影錯誤(igraph,RStudio)
# Start
set.seed(7)
setwd("C:/Users/Stefan/Desktop/")
data <- read.csv("example.csv", sep=";")
summary(data)
library(igraph)
## using subset function to select 2 variables
data_new <- subset(data, select=c(justification, claimant_function))
data_new
g <- graph.data.frame(data_new, directed = FALSE)
g
col <- c("steelblue1", "white")
shape <- c("circle", "square")
# creating bipartite network
V(g)$type <- FALSE
V(g)$type[V(g)$name %in% data_new[, 1]] <- TRUE
is.bipartite(g)
# TRUE
plot(g, layout = layout.kamada.kawai,
vertex.shape = shape[as.numeric(V(g)$type) + 1],
vertex.color = col[as.numeric(V(g)$type) + 1],
edge.color = 'gray')
# bipartiate projection
one_mode_networks <- bipartite.projection(g)
# Error in .Call("R_igraph_bipartite_projection", graph, types,
# as.integer(probe1), :
# At bipartite.c:198 : Non-bipartite edge found in bipartite projection,
# Invalid value
一切順利,除了投影指示。所以,代碼不是問題。也許錯誤/問題可能在數據本身。由於我已經使用這些數據已經有一段時間了,我認爲,我的專業態度是盲目的。如果其他人可以查看發佈的示例數據並提出建議,可能會出現什麼情況,那將是非常好的。
任何幫助非常歡迎!
大。你的回答正是我所期待的(並指出我在其他數據集中的其他「編碼相似性」)。非常感謝! –