仅显示特定标签,使用特征向量中心性(R 中的 igraph)
Display only specific labels, using eigenvector centrality (igraph in R)
我正在使用 rstudio version 0.99.879 and igraph 版本 1.0.1。
我的问题和很相似。我已将我的后续问题作为评论发布在那里,但被要求打开一个新问题。
我还想只显示特定的顶点标签,如果您使用 degree or betweenness centrality function. However, I tried it with eigenvector or hub 中心性,这就可以正常工作,它显示以下错误
Error in ifelse(evcent(g) > 0.1, V(g)$name, NA) : (list) object
cannot be coerced to type 'double'
代码如下:
#random graph
library(igraph)
g <- graph( c("John", "Jim", "Jim", "Jack", "Jim", "Jack", "Brian", "John", "John", "Janis", "Janis", "Jennifer", "Justin", "John"),
isolates=c("Jesse", "Brian") )
# works perfectly fine
par(mfrow=c(1,2), mar=c(0,0,1,0))
plot(g, vertex.size=9,
vertex.label = ifelse(betweenness(g) > 0, V(g)$name, NA),
edge.arrow.size=.5)
plot(g, vertex.size=9,
vertex.label = ifelse(degree(g) > 0, V(g)$name, NA),
edge.arrow.size=.5)
#does not work
plot(g, vertex.size=9,
vertex.label = ifelse(evcent(g) > 0.01, V(g)$name, NA),
edge.arrow.size=.5)
# I also tried this with no success
eig <- evcent(g)
par(mfrow=c(1,1), mar=c(0,0,1,0))
plot(g, vertex.size=9,
vertex.label = ifelse(eig$vector > 0.1, V(g)$name, NA),
edge.arrow.size=.5)
如何解决这个问题。这到底是什么意思:
'type double'
在此先感谢您的帮助!
查看帮助页面 ?evcent
。它说:
Value
A named list with components: ...
你需要使用
ifelse(evcent(g)$vector > 0.01,
同样,使用hub_cent$vector
我正在使用 rstudio version 0.99.879 and igraph 版本 1.0.1。
我的问题和
我还想只显示特定的顶点标签,如果您使用 degree or betweenness centrality function. However, I tried it with eigenvector or hub 中心性,这就可以正常工作,它显示以下错误
Error in ifelse(evcent(g) > 0.1, V(g)$name, NA) : (list) object cannot be coerced to type 'double'
代码如下:
#random graph
library(igraph)
g <- graph( c("John", "Jim", "Jim", "Jack", "Jim", "Jack", "Brian", "John", "John", "Janis", "Janis", "Jennifer", "Justin", "John"),
isolates=c("Jesse", "Brian") )
# works perfectly fine
par(mfrow=c(1,2), mar=c(0,0,1,0))
plot(g, vertex.size=9,
vertex.label = ifelse(betweenness(g) > 0, V(g)$name, NA),
edge.arrow.size=.5)
plot(g, vertex.size=9,
vertex.label = ifelse(degree(g) > 0, V(g)$name, NA),
edge.arrow.size=.5)
#does not work
plot(g, vertex.size=9,
vertex.label = ifelse(evcent(g) > 0.01, V(g)$name, NA),
edge.arrow.size=.5)
# I also tried this with no success
eig <- evcent(g)
par(mfrow=c(1,1), mar=c(0,0,1,0))
plot(g, vertex.size=9,
vertex.label = ifelse(eig$vector > 0.1, V(g)$name, NA),
edge.arrow.size=.5)
如何解决这个问题。这到底是什么意思:
'type double'
在此先感谢您的帮助!
查看帮助页面 ?evcent
。它说:
Value
A named list with components: ...
你需要使用
ifelse(evcent(g)$vector > 0.01,
同样,使用hub_cent$vector