问题
I am trying to use a function I found that serves to test the significance of an object created an igraph.
First the data and the libraries are loaded. Then, clustering is performed on the data. Finally, I use a function I found online in an attempt to calculate the significance of the clustering. However, this does not work.
Can someone please help me understand why this function for significance testing is not working?
library(igraph)
library(igraphdata)
data(karate)
cfg <- cluster_fast_greedy(karate)
plot(cfg, karate)
a = induced_subgraph(karate, cfg[[1]])
#community significance test (http://igraph.wikidot.com/community-detection-in-r)
community.significance.test <- function(graph, vs, ...) {
if (is.directed(graph)) stop("This method requires an undirected graph")
subgraph <- induced.subgraph(graph, vs)
in.degrees <- degree(subgraph)
out.degrees <- degree(graph, vs) - in.degrees
wilcox.test(in.degrees, out.degrees, ...)
}
#test the significance of the first community
aa = community.significance.test(karate,a)
Error in as.igraph.vs(graph, vids) :
'list' object cannot be coerced to type 'double'
Thanks
来源:https://stackoverflow.com/questions/64961299/r-significance-testing