Motivation

If you want to use the statistical software package R to do social network analysis (or just network analysis in general), you might be overwhelmed by all the R documentation that is completely missing a simple explanation of how to get a network into R and do stuff with it. Or, you might be getting tired of test.net and flo and all the rest, and want to try things out on your own network dataset.

Using

  • A Windows Vista, 64-bit HP Pavilion laptop
  • R 2.7.1
  • A text editor that handles crlf’s well, like WordPad

Setup

All you really need to do a simple network analysis is your EDGE LIST. This is a text file with two columns of data: the leftmost column will contain the ID of the “source” node, and the column on the right has the ID of the “target” node. It is up to you to keep your node ID’s straight (maybe by managing another file, your NODE LIST, that tells you what the node ID’s are and what each node represents).

Here is an example of what your edgelist might look like:

52 54
52 55
52 39
52 56
52 57
52 58
52 59
52 3
52 60
52 61
52 47
52 62
52 63
52 12
51 112
51 113
51 114
51 115
53 115
53 119
53 120
53 54
53 121
53 127
53 128
53 14
53 171

To get this into R, first save the edgelist to the default directory for R (mine is the “Documents” section that pops up whenever I launch Windows Explorer). You might prefer to do this differently. I’ll store this data as “edge.list”. You can get a quick plot of the network like this:

library(network)
edges <- read.table("edge.list")
nw <- network(edges)
plot(nw,displayisolates=FALSE)

You don’t need the “displayisolates” option, but it makes the graph cleaner. My test data was put together rather haphazardly and there are lots and lots of isolates.The network looks like this:

edge-list

Alternatively you can explore this data as an igraph object (note that we “read.graph” instead of “read.table” this time):

library(igraph)
g <- read.graph("edge.list")
summary(g)
plot(g)

The network looks something like this:

edge-as-igraph

The summary command tells you a little about your data set. The plot command launches a new window showing your network. There are tons of options that come with plot… try “plot(g,layout=layout.circle)” or “plot(g,layout=layout.kamada.kawai)” for some alternatives.

On the US frontpage to the Ubuntu shop, there are 6 friendly people wearing copies of the same shirt that says, “I do it with ubuntu.” Where are these people? I’d like to hang out with them.

As I reflected on my engineering values this evening over a good cup of coffee, I noticed a common theme: I value underwhelming, useful tools.

Many of the underwhelming, useful tools I value (including tools which have been around for decades along with those which are only ideas in my head) fall into two distinct categories:

  • web applications
  • command-line tools

By underwhelming, I mean distinctly not overwhelming, not even remotely so, though Merriam-Webster defines underwhelming as “failing to impress or stimulate.” Perhaps both are accurate to my point. If a software tool is simple and all too useful, it no longer feels like software, it fails to continue to impress, and is able to become one with your activity space.

Not all underwhelming tools are useful, which is why I value tools both underwhelming and useful. When a tool is overwhelming, it may be difficult to understand its utility. When a tool is underwhelming, its utility quickly presents itself.

I find this blog underwhelming at times… :-P Now to make it useful…

Motivation

I use the control key a lot. Between my Fluxbox keys file shortcuts, several Xterms with bash, and Emacs, the pinky on my left hand is getting worn out quickly. It may not seem productive at first, but every engineer should spend some time setting up the simple things in his or her lab, including getting a comfortable keyboard.

Using

  • a standard US keyboard
  • a UNIX-like system running an X windows server (if you are on a UNIX-like system and have a graphical display, you are probably running X windows)
  • xmodmap

Setup

Here is my $HOME/.Xmodmap file:

! map Caps Lock key to Control
remove Lock = Caps_Lock
keysym Caps_Lock = Control_L
add Control = Control_L

! map right Windows/Super key to Caps Lock
remove Mod4 = Super_R
keysym Super_R = Caps_Lock
add Lock = Caps_Lock

To activate it, wait until you restart X or run from the command line:

$ xmodmap $HOME/.Xmodmap

Done. Now I just need to break the Control_L habit. Fortunately, I kept that key mapped as Control_L so it still works as expected. This feels like the old days in the UNIX workstation lab, except that my keyboard is much, much cleaner.