I am trying to use the 'networkD3' library in R to create a chord diagram for my data. I am following the logic presented in this stackoverflow post: Network chord diagram woes in R
I am particularly interested in creating a chord diagram using 'igraph' and 'networkd3', since I do not have administrative rights on my computer to install other libraries (such as "circlize").
I created some fake data in R:
library(igraph)
library(dplyr)
library(networkD3)
#create file from which to sample from
x5 <- sample(1:100, 1100, replace=T)
#convert to data frame
x5 = as.data.frame(x5)
#create first file (take a random sample from the created file)
a = sample_n(x5, 1000)
#create second file (take a random sample from the created file)
b = sample_n(x5, 1000)
#combine
c = cbind(a,b)
#create dataframe
c = data.frame(c)
#rename column names
colnames(c) <- c("a","b")
Next, I created an adjacency matrix:
#create adjacency matrix
g1 <- graph_from_adjacency_matrix(c)
The problem happens when I try to create the Chord Network from the adjacency matrix:
chordNetwork(Data = c,
width = 500,
height = 500,
)
Error in chordNetwork(Data = g, width = 500, height = 500, ) :
Data must be of type matrix or data frame
Does anyone know what I am doing wrong?
Thanks