I am a novice who is working on a data to calculate directed degree centrality by editing R code my senior already made.
This is the part of code I have:
library(igraph)
net <- graph_from_data_frame(df2, directed = T)
V(net)$degree <- net %>% degree(., mode="out")
degree <- net %>% degree(., mode="out")
But the difference between my senior’s data and mine is that in my data there are some cases that A gives B multiple types of information(Ex.production information and marketing information), meaning there are more than one edge between A and B.
From what I’ve found, ‘igraph’ is said to treat multiple edges formed between two nodes as one.
How should I solve this problem? I want to count every edge separately.
(By the way I’ve tried weighted degree centrality with frequency of information provision but it’s deviation is too large)
Here’s the result from dput(head(df2, 5):
dput(head(df2, 5))
df2 <-
structure(list(
source = c("Thai name 1", "Thai name 2", "Thai name 3", "Thai name 4", "Thai name 5"),
target = c("A108", "A113", "A245", "A085", "A250"),
relationship = c(1, 6, 5, 4, 4),
outside = c(0, 0, 0, 0, 0),
`information code` = c(1, 1, 2, 1, 2),
adoption = c(0, 1, 1, 1, 1),
frequency = c(1, 5, 5, 5, 5),
village = c(" Village No.5", " Village No.5", " Village No.5", " Village No.5", " Village No.5")),
row.names = c(NA, 5L), class = "data.frame")
Thank you for your help!
Hwani Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.