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)) #Transform into an unweighted, directed, twomode igraph object (optional, only for unweighted analysis), otherwise jump to #multiply the transposes... and proceed with M instead of M2 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 (optional) M2 <- as_incidence_matrix(two_mode_network_ni, names = TRUE) # multiply the transpose of M by M -> create a onemode network of concepts om_concept_actor <- t(M2)%*%(M2) # multiply M by the transpose of M -> create a onemode network of actors om_actor_concept <- (M2)%*%t(M2) # set diagonals to zero diag(om_actor_concept)<-0 diag(om_concept_actor)<-0 write.table (om_concept_actor, file ="om_concept_nonorm.csv", dec = ".", sep = ";", col.names = NA) write.table (om_actor_concept, file = "om_actor_nonorm.csv", dec = ".", sep = ";", col.names = NA) write.table (M2, file = "tm_unweighted.csv", dec = ".", sep = ";", col.names = NA)