0 down vote favorite <https://stackoverflow.com/questions/44084090/stanford-sna-lab-3-error-in-exercise#>
I am following this lab exercise on community detection https://sna.stanford.edu/lab.php?l=3 since in their program community.to.membership was deprecated i modified their code. Original code is at https://sna.stanford.edu/lab.php?l=3 Line 251 onwards. My code: library(sna) gadj: //adjacency matrix of a graph with 106 rows. ideal_observed_cors = vector() num_vertices = nrow(gadj)-1 for (i in 0:(num_vertices-1)) { num_comms = (num_vertices - i) cat('number of communities: ', num_comms, '\n') community <- list(cutat(wc, steps=i)) //replaced community.to.membership with cutat names(community)=c("membership") print(community) idealized_comm_mat <- matrix(nrow=num_vertices, ncol=num_vertices) for (m in 1:num_vertices) { for (n in 1:num_vertices) { if (m==n) { idealized_comm_mat[m,n] = 0 } else if (community$membership[m] == community$membership[n]) { idealized_comm_mat[m,n] = 1 } else { idealized_comm_mat[m,n] = 0 } } } print(idealized_comm_mat) if (num_comms > 1 & num_comms < num_vertices) { ideal_observed_cors <- append(ideal_observed_cors, (gcor(idealized_comm_mat, gadj))) print(ideal_observed_cors[length(ideal_observed_cors)]) } else { ideal_observed_cors <- append(ideal_observed_cors, 0) print('unable to calcuate correlation; setting value to 0') } cat('\n')} ideal_observed_cors <- rev(ideal_observed_cors) ideal_observed_cors plot(ideal_observed_cors) But i am getting error number of communities: 105 [1] "unable to calcuate correlation; setting value to 0" number of communities: 104 Error in as.sociomatrix.sna(dat2) : as.sociomatrix.sna input must be an adjacency matrix/array, network, or list. -- Warm and Kind regards, *Pranav .A.Nerurkar* *Student* *Dept of Computer Engineering* *Veermata Jijabai Technological Institute* *Matunga, Mumbai, Maharashtra.* *Ph: 9619997797*
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
