-1

Since I need normalized scores, I wanted to call the degree() function on my adjacency matrix I got from a text file I loaded into R using read.delim. That went perfectly fine with the sna package.

When I run

K3_T2_ACAD <- diag.remove(read.delim("K3_T2_ACAD.txt", header = TRUE, 
                                      sep = "\t", row.names = 1), remove.val=0)

and then

K3_T2_ACAD_indeg <- degree(K3_T2_ACAD, g=1, nodes=NULL, gmode="digraph", 
                           diag=FALSE, tmaxdev=FALSE, cmode="indegree")

it works!

I tried detaching the sna functions because I thought that was the problem. However, when I run the igraph degree() function, it does not work:

K3_T2_ACAD_indeg2 <- degree(K3_T2_ACAD, mode ="in", loops = FALSE, normalized = TRUE)

returns

Error in degree(K3_T2_ACAD, mode = "in", loops = FALSE, normalized = TRUE) : Not a graph object

The first column and row each contain the participant codes. Is it possible, that igraph cannot work with that, whereas sna can?

martin
  • 3,149
  • 1
  • 24
  • 35
Latroe
  • 1
  • 3
  • Please check out [how to make a reproducible question](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for tips to improve your post. If we can't run some code and get the same error as you, it's hard to help you. – MrFlick Mar 16 '15 at 16:20
  • I'm afraid I don't know how I should do that in this case – Latroe Mar 16 '15 at 16:38

1 Answers1

1

The sna package uses adjacency matrices, igraph does not not. You need to create an igraph object to work on. See e.g. http://igraph.org/r/doc/aaa-igraph-package.html

Gabor Csardi
  • 10,705
  • 1
  • 36
  • 53