![](/img/trans.png)
[英]Plot only nodes of a specific date for a social network in R using igraph
[英]Features do not show on Network plot in R using igraph
我创建了一个包含 44 个功能的网络 plot,但功能的名称没有显示在我的网络 plot 中。 当我运行我的代码时,此错误显示:
Error in symbols(x = coords[, 1], y = coords[, 2], bg = vertex.color, :
无效的符号参数
我试过这个: Unable to plot a network on igraph ,但没有任何效果。
有谁知道我应该改变什么? 这是我的代码:
co <- filter(data) %>%
select(-q, -ID) %>%
cor()
library(igraph)
g <- graph.adjacency(co,
weighted = TRUE,
diag = FALSE,
mode = "upper")
cut.off_b <- mean(E(g)$weight)
g_2 <- delete_edges(g, E(g)[weight < cut.off_b])
c_g_2 <- cluster_fast_greedy(g_2)
plot(c_g_2, g_2,
vertex.size = colSums(co) * 10,
vertex.frame.color = NA,
vertex.label.color = "black",
vertex.label.cex = 0.8,
edge.width = E(g_2)$weight * 15,
layout = layout_with_fr(g_2),
main = "Network")
输出(co):
structure(c(1, .07977915371083, 0.152143694525588, -0.0218189826329971, 0.0485372722131193, 0.000923129223941082, -0.0222534655849573, 516, 1, -0.205361264538372, -0.149616273645181, 0.241437784766734, -0.140457111733162, 0.52697977722007, 0.588437224079489, -0.00263277091969263, 0.22151603150994, 0.245933601749799, 0.0485372722131193, -0.205361264538372, 1, 0.409240797220096, -0.444516191462303, -0.0553258405959017, 0.224169841776048, 0.286458842414816, -0.00708372057991018, 0.175543278780438, 0.190122437013223, 0.000923129223941082, -0.149616273645181, 0.409240797220096, 1
这是我的 plot:
我想您可以在plot
中尝试abs(colSums(co)*10)
的vertex.size
,因为它应该始终是正值。 一个例子如下
plot(
c_g_2, g_2,
vertex.size = abs(colSums(co) * 10),
vertex.frame.color = NA,
vertex.label.color = "black",
vertex.label.cex = 0.8,
edge.width = E(g_2)$weight,
layout = layout_with_fr(g_2),
main = "Network"
)
虚拟数据
co <- cor(mtcars)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.