1

I want to visualize a dynamic network using the ndtv package in R.

My dataset (data) looks like this:

0 1 Apple Banana
0 1 Peach Banana
0 1 Apple Strawberry
1 2 Apple Banana
1 2 Apple Peach
2 3 Banana Peach
…

So the columns are onset, terminus, tail, head.

If I want to create a networkDynamic object from this list by

nw <- networkDynamic(edge.spells=data)

I get an error saying "the tail column of the edge.spells argument to networkDynamic must be a numeric vertex id". So I guess I need to convert those strings into numeric values. How do I do that? And if I do that, how do I keep the names? I don't want a network that just displays the numeric IDs of those names, I want to see those names in the network. I couldn't find any useful information by searching the web, and this tutorial doesn't show what I want to do. I would've liked to see how they actually constructed the short.stergm.sim data instead of just using it.

Any help is very much appreciated!

1 Answers1

1

I found a way to map ids to the names.

names <- unique(c(data$head,data$tail))
data$head <- match(data$head,names)
data$tail <- match(data$tail,names)

And then I could create the networkDynamic object

nw <-networkDynamic(edge.spells=data)

and add the names to the network

network.vertex.names(nw) <- names

This post helped me a lot.