I am a beginner in R. I have a row standardized matrix (1542x1542) that I created in excel and saved as a .csv file. I am trying to use the matrix in R to calculate Moran's I. -using the following command:
# Weights Matrix Based on Connectivity
sw <- read.csv(file = "20210929_Weights_Matrix.csv")
sw.2.mat <- as.matrix(sw)
## mat to listw
mat2listw(sw.2.mat)
dnn.2.listw = nb2listw(sw.2.mat, zero.policy=T)
However, when I run the command I get the following errors
sw <- read.csv(file = "20210929_Weights_Matrix.csv")
sw.2.mat <- as.matrix(sw)
mat2listw(sw.2.mat) Error in mat2listw(sw.2.mat) : x must be a square matrix
dnn.2.listw = nb2listw(sw.2.mat, zero.policy=T)
Error in nb2listw(sw.2.mat, zero.policy = T) : Not a neighbours list
When I try to add an additional row in excel, I get the following error in R
sw <- read.csv(file = "20210929_Weights_Matrix.csv")
sw.2.mat <- as.matrix(sw)
## mat to listw
mat2listw(sw.2.mat)
Error in if (any(x < 0)) stop("values in x cannot be negative") :
missing value where TRUE/FALSE needed
dnn.2.listw = nb2listw(sw.2.mat, zero.policy=T)
Error in nb2listw(sw.2.mat, zero.policy = T) : Not a neighbours list
Could someone please help? Is there a possibility I can share my excel?