Skip to content

Instantly share code, notes, and snippets.

@sckott
Created October 14, 2011 16:11
Show Gist options
  • Save sckott/1287545 to your computer and use it in GitHub Desktop.
Save sckott/1287545 to your computer and use it in GitHub Desktop.
Playing with the Otago Harbor food web dataset.
# Blog post about a new food web
> require(ggplot2); require(igraph); require(bipartite); require(NetIndices)
# read in edge list
> mygraph <- read.graph("/Mac/R_stuff/Blog_etc/newfoodweb/edgelist_new.txt",
+ format = "edgelist")
> str(mygraph)
List of 9
$ : num 181
$ : logi TRUE
$ : num [1:1924] 4 4 4 5 5 5 5 5 5 5 ...
$ : num [1:1924] 1 4 6 1 2 3 4 5 6 12 ...
$ : num [1:1924] 0 1 2 1812 1813 ...
$ : num [1:1924] 0 3 61 142 184 186 404 407 413 415 ...
$ : num [1:182] 0 0 0 0 0 13 61 61 109 126 ...
$ : num [1:182] 0 0 21 91 114 120 158 220 220 220 ...
$ :List of 4
..$ : num [1:2] 1 0
..$ : Named list()
..$ : list()
..$ : list()
- attr(*, "class")= chr "igraph"
# igraph graphs
> plot.igraph(as.undirected(mygraph),
+ vertex.label = NA,
+ vertex.size = 1)
> plot.igraph(as.undirected(mygraph),
+ layout = layout.circle,
+ vertex.label = NA,
+ vertex.size = 1)
# my own little function, gggraph
> source("/Mac/R_stuff/Blog_etc/newfoodweb/gggraph.R")
> gggraph(mygraph, vplace = rnorm, method = "igraph", trophic = "FALSE")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment