Last active
July 27, 2019 06:57
-
-
Save wmichi/cfed8d8395a91497aae999acb1d52cb4 to your computer and use it in GitHub Desktop.
Create network graph with r
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(network) | |
df <- read.csv('tmp/op_net.csv', header=FALSE, sep=' ', stringsAsFactors = FALSE) | |
df <- df[2:nrow(df),] | |
num_edges <- nrow(df) | |
edgelist <- matrix("",nrow= num_edges,ncol = 2) | |
for(i in 1:num_edges){ | |
edgelist[i,1] <- df[i,1] | |
edgelist[i,2] <- df[i,2] | |
} | |
op_net <- network(edgelist, directed=FALSE) | |
plot.network(op_net, displaylabels=T) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment