简体   繁体   English

具有三维边缘列表的网络?

[英]Network with three-dimensional edgelist?

I have data which provides information on flows by actor c, broken down by inputs originating from source s, to partner p.我有数据提供有关参与者 c 的信息流,按源自源 s 的输入细分到合作伙伴 p。

Network data normally has only one information: Data / Information flows from A->B, B->C etc.网络数据通常只有一种信息:数据/信息流从 A->B、B->C 等。

However, my data shows which flows from A->B then goes to C, and which from A->B goes to D.但是,我的数据显示哪些从 A->B 流向 C,哪些从 A->B 流向 D。

The data is structured as a three-column edgelist.数据结构为三列边缘列表。

source <- c("A", "D", "B", "B")
country <- c("B", "B", "A", "A")
partner <- c("C", "C", "C", "D")
value <- c("5", "0", "2", "4")

df <- data.frame(source, country, partner, value)

df

I kinda dont see how it would be possible to use this as network data - however, if anyone got an idea on how to use that way more fine-grained network that be amazing ((:我有点不明白如何将其用作网络数据 - 但是,如果有人知道如何使用这种方式的更细粒度的网络是惊人的(((:

best,最好的事物,

moritz莫里茨

Maybe like this:也许是这样的:

library(igraph)

g <- graph_from_data_frame(
  rbind(
    setNames(df[, c(1, 2, 4)], c("from", "to", "value")),
    setNames(df[, c(1, 3, 4)], c("from", "to", "value"))
  )
)

plot(g)

在此处输入图片说明

I am not sure if the code below is what you want我不确定下面的代码是否是你想要的

library(igraph)
v <- c(3,1)
g <- Reduce(union,lapply(v, function(k) graph_from_data_frame(df[-k])))

such that plot(g) gives这样plot(g)给出

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM