I am trying to do a network analysis and after some qualitative data about culture I want to see how my culture nodes are related to each other. To do this I created a csv file in Excel with 46 rows and columns, aka it is a squared matrix. I tried the following two sets of code to get a network output in R.
First attempt (did not work):
library(igraph)
my_data <- read.csv(file.choose(),header=TRUE, row.names=NULL)
my_matrix <- as.matrix(my_data)
my_first_network <-
graph.adjacency(my_matrix,mode="undirected",diag=FALSE)
my_first_network
plot(my_first_network)
I got these errors:
Error in graph.adjacency.dense(adjmatrix, mode = mode, weighted = weighted, :
At structure_generators.c:274 : Non-square matrix, Non-square matrix
In addition:
Warning message:
In mde(x) : NAs introduced by coercion
Second attempt (also didn't work):
my_data <- read.csv(file.choose(),sep=",",header=TRUE)
nodelist <- names(my_data)[-1]
my_matrix <- as.matrix(my_data) [,-1]
rownames(my_matrix) <- colnames(my_matrix) <- nodelist
my_matrix
library(igraph)
g <- graph_from_adjacency_matrix(my_matrix, mode="undirected",
weighted=NULL)
plot(g)
Got these errors:
Error in graph.adjacency.dense(adjmatrix, mode = mode, weighted = weighted, :
At structure_generators.c:274 : Non-square matrix, Non-square matrix
Could anybody help me by telling me what the problem is, how I can fix the code to get my network?
Thank you very much in advance
dim(my_matrix)? - G5Wmy_matrix) and tell us the output. - G5W