Reputation: 1371
I intend to get some statistics on a network using the igraph package.
model1 <- ug(~a:b, ~a:c:d,~b:c)
> model1
A graphNEL graph with undirected edges
Number of Nodes = 4
Number of Edges = 5
Problem: using the function:
cluster.distribution(model1)
returns
Error in cluster.distribution(model1) : Not a graph object.
Now if I apply the function:
degree(model1)
i get the same error:
Error in degree(model1) : Not a graph object
however if I detach the igraph package i get:
> detach("package:igraph", unload=TRUE)
Warning message:
'igraph' namespace cannot be unloaded:
namespace 'igraph' is imported by 'gRbase', 'gRain' so cannot be unloaded
> degree(model1)
a b c d
3 2 3 2
I assume the problem is related the the packages, but my R skill don't go so far as that I would be able to figure this problem out by myself.
> search()
[1] ".GlobalEnv" "package:gRain" "package:grid"
[4] "package:gRbase" "package:graph" "tools:rstudio"
[7] "package:stats" "package:utils" "package:datasets"
[10] "package:methods" "Autoloads" "package:base"
I am really interested in using the function from the igraph package so please help me figure out why I get this error even though it is obviously a graph object.
Thx!
Upvotes: 0
Views: 14308
Reputation: 94277
You seem to be trying to use the graph
package and the igraph
packages. Objects created with one can't be used in functions from the other, it seems.
The igraph
objects are of class igraph
> g=graph.full(4)
> class(g)
[1] "igraph"
whereas the object you created with ug
has come from the graph
package and so is a different class.
I'd test this myself, but currently the graph
package has been removed from CRAN and I'm not in the mood to go chasing it from the archives:
http://cran.r-project.org/web/packages/graph/index.html
Upvotes: 4