I am new to STATNET and know nothing about it. I have a data set which has 3 columns. The first and second column contain nodes whereas the third contains edge value. How should I import this to STATNET? I suspect I need to convert this dataset to a matrix. How can I do that in R?
Asked
Active
Viewed 349 times
1 Answers
2
No need to change it into a matrix, you can use a weighted edgelist right away. Try something like
library(statnet)
dat <- structure(
list(a = c(1, 2, 4), b = c(2, 3, 5), c = c(10, 1, 1)),
.Names = c("a", "b", "c"),
row.names = c(NA, -3L),
class = "data.frame"
)
g <- as.network(
dat,
ignore.eval = FALSE,
names.eval = 'weight',
matrix.type = 'edgelist',
directed = FALSE
)
-
thanks. How can I draw the network? do you know any good resource for learning statnet? – duckman Dec 07 '17 at 08:41
-
You can use something like `plot.network(g,edge.lwd = get.edge.value(g,"weight"))`. I don't know a comprehensive tutorial for `statnet` but you could also look into the `igraph` library which is quite popular and has tons of documentation. Finally consider accepting the answer if it helped you – CER Dec 07 '17 at 17:51
-
do you want me to help you to plot? – eli May 29 '20 at 21:54