摘要: 我试图找到大量数字之间的联系。尽管数字与ID相关,但我尝试查看数字本身之间的相关性/方向(因为数字在多个ID之间重复。
背景
这是针对正在工作的项目的。我已经成功利用ID和Nbr变量[d3.js]应用了一个强制定向网络。但是,不仅网络规模庞大,而且我们不需要脚趾ID。我们对查看哪些数字相互连接更感兴趣。
目标(结果):
类似于以下的网络矩阵:
#If Nbr1 and Nbr 2 appear across three ids and Nbr1 and Nbr 4 appear across 5 ids, the resulting network would be:
Nbr1 Nbr2 Weight
777555111 777555112 3
777555111 777555114 5
显示一些代码:
set.seed(123)
options(scipen=999)
NumbersTable<-data.table(
ID=sample(1:5,5000,replace = T),
Nbr=sample(7775551111:7775551115,5000,replace = T))
#Reorder data by IDs
NumbersTable<-NumbersTable[order(NumbersTable$ID),]
由于网络程序包需要节点和边缘,因此不确定从何而来。