In R programming - How do I plot a network visualization graph given a matrix X with a 2 column coordinate system:
coordinates <- matrix(c(0.809,0.588,0.309,0.951,-0.309,0.951,-0.809,0.588,-1,0,-0.809,-0.588,-0.309,-0.951,0.309,-0.951,0.809,-0.588,1,0), ncol=2)
...and a quadratic matrix Y as an adjacency matrix:
adjacency <- matrix(c(0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0), ncol=10)
Unfortunately I can only use the standard R Library (that which is pre-installed) and that's why I'm having a hard time figuring it out...
What I have tried:
So far I have this code but the graph it creates is quite "ugly" and gives me a ton of errors:
plotGraph <- function(B){
coordinates <- matrix(c(0.809,0.588,0.309,0.951,-0.309,0.951,-0.809,0.588,-1,0,-0.809,-0.588,-0.309,-0.951,0.309,-0.951,0.809,-0.588,1,0), ncol=2)
adjacency <- matrix(c(0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1,0,0,1,0), ncol=10)
plot(coordinates)
idx <- which(adjacency>0, arr.ind = T)
number = ncol(adjacency) * nrow(adjacency)
for(i in 1:number){
arrows(coordinates[idx[i,1],1], coordinates[idx[i,1],2], coordinates[idx[i,2],1], coordinates[idx[i,2],2])
}
}