Here are a few things that I have learnt while working with R network objects, using the
sna packages (the last two packages go well together).
This note is only concerned with some quirky internals of the packages mentioned above. For network visualization, readers should head to Katherine Ognyanova's excellent tutorial.
igraph package implements more placement algorithms than the
sna package does, and its implementations tend to accept more parameters, such as edge weights for the Fruchterman-Reingold and Kamada-Kawai algorithms.
As of version 1.1.0 of the package, edge rewiring does not play well with edge attributes. This is a serious issue if the aim of the rewiring is to randomise an edge value.
There are two different methods to set edge values on a
set.edge.value. The functions work identically, but perform completely different assignments.
Reading through the package documentation too quickly, I missed the subtle difference between
set.edge.attribute, which assigns values to edges in “sequential order”, and
set.edge.value (or the
%e% method, which is a shortcut for it), which assigns values in “adjacency matrix form”.
There is extensive namespace overlap between
sna. Consequently, loading the packages together can be error-prone.
This pull request illustrates the problem through the
degree function of the
sna package. The function calls another
sna function, which itself calls the
is.bipartite function, expecting it to be that of the
network package. If the
igraph package has been loaded after the
network package, this function will have been masked and the code will break.
- First published on September 17th, 2015