I have a edge list for which I want to determine similarity measures using R.
Edge list
Table 1
c1 c2
Algeria Andorra
Algeria Angola
Algeria Antigua and Barbuda
Algeria Argentina
Algeria Armenia
Algeria Australia
Algeria Austria
Algeria Azerbaijan
Algeria Bahamas
Algeria Bahrain
Algeria Bangladesh
Algeria Barbados
Algeria Belarus
Andorra USA
I am using igraph
library (igraph)
data<- read.csv(file.choose(), header =TRUE)
network<- graph.data.frame(data, directed = FALSE)
results<- ( similarity(
network,
vids = V(network),
mode = c("all"),
loops = FALSE,
method = c("jaccard")))
From this, I get the similarity index as
Table 2
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0769
0 1 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0 0.5 1 1 1 1 1 1 1 1 1 1 1 1 0
0.0769 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Now, I would like to have this information as follows:
The similarity index for all possible pairs.
Table 3
c1 c2 jaccard_index
Algeria Andorra 0
Algeria Angola 0
Algeria Antigua and Barbuda ...
Algeria Argentina
Algeria Armenia
Algeria Australia
Algeria Austria
Algeria Azerbaijan
Algeria Bahamas
Algeria Bahrain
Algeria Bangladesh
Algeria Barbados
Algeria Belarus
Algeria USA
Andorra USA
Andorra Angola
Andorra Antigua and Barbuda
Andorra Argentina
Andorra Armenia
Andorra Australia
Andorra Austria
Andorra Azerbaijan
Andorra Bahamas
Andorra Bahrain
Andorra Bangladesh
Andorra Barbados
Andorra Belarus
.... ... ....
Is there a simple way to get the information as in Table 3?
Any tips appreciated.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…