setwd("...") #insert your work directory library (igraph) #for network analysis # Load matrix from csv M = as.matrix(read.csv(file.choose(), sep = ";", header = T, row.names = 1, check.names=FALSE)) #Transform into an unweighted, directed, twomode igraph object (Jaccard works best with unweighted binary matrices) two_mode_network - graph.incidence(M, directed = TRUE, mode = "out", weighted = NULL) # Delete isolates from the twomode network (optional) Isolated - which(degree(two_mode_network)==0) two_mode_network_ni - delete.vertices(two_mode_network, Isolated) class(two_mode_network_ni) # Transform twomode back to an incidence matrix M2 - as_incidence_matrix(two_mode_network_ni, names = TRUE) write.table (M2, file = "tm_unweighted.csv", dec = ".", sep = ";", col.names = NA)