Hi Misi,

I am not entirely sure what’s is happening. If you send me an email with your data and code, I will have a look at it.

Tore

]]>great, this solved my initial problem, very sorry I missed such a basic problem. Now after running:

g2uptn <- cbind(get.edgelist(g2up, names=TRUE), E(g2up)$weight)

colnames(g2uptn)<-c("i", "j", "w")

g2uptn2 <- data.frame(g2uptn , row.names = NULL)

class(g2uptn2[,1])

[1] "factor"

g2uptn2$i <- as.numeric(as.character(g2uptn2$i))

g2uptn2$j <- as.numeric(as.character(g2uptn2$j))

g2uptn2$w <- as.numeric(as.character(g2uptn2$w))

class(g2uptn2[,1])

[1] "numeric"

g2uptn2 <- symmetrise_w(g2uptn2)

I get the following new error message:

Error in as.tnet(net, type = "weighted one-mode tnet") :

Not all node id's are integers

In addition: Warning message:

In as.tnet(net, type = "weighted one-mode tnet") :

NAs introduced by coercion to integer range

Now, this is surprising as I do think that all my IDs are integers and there are no NAs, I manually checked all 3000 of them. This is my first few lines:

i j w

1 5562859370 5560510272 1

2 5562859370 5567267488 2

3 5562859370 5567066088 1

4 5562859370 5567980031 1

5 5562859370 5561400283 1

6 5562859370 5564857984 1

7 5562859370 5567137962 1

8 5562859370 5566225347 1

9 5562859370 5566862503 1

10 5562859370 5561852103 1

Any ideas on what may cause this new error?

Best,

Misi

Hi Misi,

Glad you are finding the library useful. tnet is written to handle networks with integer/numeric node identifiers. Based on your error messages, it seems that the data class for the identifiers is factor. Try to type class(g2uptn[,1]) to see the data class. Also, you might want to turn of names=TRUE in the igraph function get.edgelist.

Best,

Tore

your tnet library is great! I have a problem importing data from igraph though. I followed your instructions above which work fine, but result in an edgelist which has vertex ranks as IDs rather than the vertex IDs I would like to use (numeric company IDs such as “5565877668”). I run the following starting from my “g2up” igraph data.frame:

g2uptn <- cbind(get.edgelist(g2up, names=TRUE), E(g2up)$weight)

if(!is.directed(g2up))

g2uptn <- symmetrise_w(g2uptn)

g2uptn <- as.tnet(g2uptn , type="weighted one-mode tnet")

which gives me the following error message: "Error in Ops.factor(net[, "i"], net[, "j"]) : level sets of factors are different"

Creating a data.frame with numeric IDs doesn't seem to solve the problem either. Running this code I run into the same error message:

g2uptn <- cbind(get.edgelist(g2up, names=TRUE), E(g2up)$weight)

colnames(g2uptn)<-c("i", "j", "w")

g2uptn2 <- data.frame(g2uptn , row.names = NULL)

if(!is.directed(g2uptn2 ))

g2uptn2 <- symmetrise_w(g2uptn2 )

g2uptn2 <- as.tnet(g2uptn2 , type="weighted one-mode tnet")

Any help would be very welcome!

Best,

Misi

Hi Ryan,

It seems you are missing line #5 in the above example. This line creates a random igraph network. Let’s connect over email if you are struggling with your own data.

Tore

]]>Using: $version.string

[1] “R version 3.3.0 (2016-05-03)”

$nickname

[1] “Supposedly Educational”

>

> # Load igraph and tnet

> library(tnet)

>

> # Create a sample igraph network with tie weights

> g E(g)$weight

> # Extract edgelist and a 1 to the node id’s as igraph starts from 0 while tnet 1.

> net

> # For binary networks, a third column of 1s must be added

> if(ncol(net)==2)

+ net

> # For undirected networks, the symmetrise function must be run

> if(!is.directed(g))

+ net

> # Ensure that it conforms to the tnet standard

> net

> clustering_tm(net)

Error in clustering_tm(net) : Network not loaded properly