I have the data like below:
A B 100
A C 100
B D 80
A D 50
B C 5
B D 60
basically three columns column 1 and Column 2 are character columns and column 3 is an integer which represents percentage of match between Col1 and Col2. Now I would like to represent this data as a correlation matrix. How can I do the same?
Here is an example on how to reconstruct the whole correlation matrix relatively simply using igraph:
library(igraph)
library(corrplot)
g <- graph.data.frame(df, directed = FALSE)
mat <- get.adjacency(g, attr = "V3", sparse = FALSE)
mat
#output
A B C D
A 0 100 100 50
B 100 0 5 60
C 100 5 0 0
D 50 60 0 0
diag(mat) <- 100
mat <- mat/100
corrplot.mixed(mat, upper = "shade", "number")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.