Skip to content

Instantly share code, notes, and snippets.

@wmichi
Last active July 27, 2019 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmichi/cfed8d8395a91497aae999acb1d52cb4 to your computer and use it in GitHub Desktop.
Save wmichi/cfed8d8395a91497aae999acb1d52cb4 to your computer and use it in GitHub Desktop.
Create network graph with r
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