I struggle with the error
Error in 1:nrow(x) : argument of length 0
Specifically, I imported a shapefile for block groups that include census tracts for the US. I am trying to compute dissimilarity, spatial proximity, absolute clustering, eta2, and isolation indexes for each census tract based on group blocks using OasisR package. The code worked for larger units using a different shapefile (Metropolitan areas based on tracts). However, now I am receiving an error I mentioned above. Here is the full code:
data<-readOGR(dsn="/Users/16033/Desktop/Exp_shapefiles_dropped", layer="Export_Output_2000b")
library(OasisR)
x<-data@data
tractlist <- unique(x$gisjoin_t1) ntract <- length(tractlist)
result <- as.data.frame(matrix(0, nrow = ntract, ncol = 6))
names(result) <- c("gisjoin_t1", "Dissim", "SpatProx","AbsClus","Eta2","Isol")
result$gisjoin_t1 <- tractlist
for (i in 1:ntract)
{ prov <- subset(x, gisjoin_t1 == tractlist[i])
result$Dissim[i] <- Atkinson(prov[,2:3])
}
... Same for other indexes.
head(data@data)
gisjoin_t1 black_n mhwhite_n his_n
0 2.0013e+11 18 231 151
1 2.0013e+11 13 127 59
2 2.0013e+11 14 163 129
3 2.0016e+11 8 279 22
4 2.0016e+11 127 949 323
5 2.0016e+11 30 831 228
Thank so much you in advance. Sylwia