R: Significance Testing

廉价感情. 提交于 2021-01-07 02:45:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!