Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Plotting Networks using igraph package in R
---
title: "Week 9 HW"
author: "Dalit Shalom"
date: "March 31, 2015"
output: html_document
---
###Require packages
require(curl)
require(igraph)
###Load packages
library("curl", lib.loc="/Library/Frameworks/R.framework/Versions/3.1/Resources/library")
library("igraph", lib.loc="/Library/Frameworks/R.framework/Versions/3.1/Resources/library")
###Set vertex dataframe
vertex=data.frame(node)
###Declare the network
network=graph.data.frame(edge,directed=TRUE,vertices=vertex)
###The two layers of information we're using
ecount(network)
V(network)
###The combination of those layers
summary(network)
###Redefining network
network <- set.graph.attribute(network, "layout", layout.kamada.kawai(network))
###Plot
plot(network,vertex.shape="circle", vertex.color="red" ,vertex.size=5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment