Reputation: 2564
I am currently trying to convert a network object to an igraph object. From various posts, I understand the intergraph
package can do this through the asIgraph()
function. I am trying to convert the classic Sampson dataset, which is found in the ergm
package. When I do:
> library(ergm)
> library(intergraph)
> library(igraph)
> data(sampson)
> class(samplike) # The network object
[1] "network"
> asIgraph(samplike)
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, :
arguments imply differing number of rows: 88, 26
I have the error above. Does anyone have any idea why it fails for this canonical dataset?
Upvotes: 1
Views: 462
Reputation: 1115
EDIT: See a recent post from two weeks ago on the
ergm
GitHub Fixed the "nominations" attribute of the sampson dataset. This was an error in the sampson dataset that has now been fixed on the GitHub version, but not yet updated to CRAN.
It's failing because the sampson
dataset has an edge attribute nominations
which only has 26 values even though there are 88 edges in the dataset. When intergraph
tries to convert to igraph
it attempts to bind the edge attributes to the edge list with asDF()
and this step fails. The simple thing is to delete the edge attribute like so:
smplk<-samplike
delete.edge.attribute(smplk, "nominations")
asIgraph(smplk)
IGRAPH dca72f1 D--- 18 88 --
+ attr: cloisterville (v/l), group (v/c), na (v/l), vertex.names
| (v/c), na (e/l)
...
It's a little unclear to me from the documentation how this attribute should map on to the edgelist, but if this can be determined it could be added in separately with set.edge.attribute
.
Upvotes: 2