thelovelab / tximport

Transcript quantification import for modular pipelines
136 stars 33 forks source link

error in 1:nrow(m): argument of length 0 #51

Closed SylwiaPiatkowska closed 2 years ago

SylwiaPiatkowska commented 2 years ago

Dear all, I struggle with the error Error in 1:nrow(x) : argument of length 0

I was hoping that tximport can help here. 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])
} After this command I am getting an error: Error in 1:nrow(x) : argument of length 0 ... Same for other indexes. Here is the first 50 observation from my file reconstructed <- structure(list(gisjoin_t1 = c(200130000100, 200130000100, 200130000100, 200160000100, 200160000200, 200160000200, 200200000101, 200200000101, 200200000101, 200200000102, 200200000102, 200200000102, 200200000102, 200200000201, 200200000201, 200200000202, 200200000202, 200200000202, 200200000202, 200200000203, 200200000203, 200200000203, 200200000203, 200200000203, 200200000204, 200200000204, 200200000300, 200200000400, 200200000500, 200200000500, 200200000600, 200200000600, 200200000600, 200200000600, 200200000600, 200200000600, 200200000600, 200200000600, 200200000701, 200200000701, 200200000701, 200200000701, 200200000702, 200200000702, 200200000702, 200200000703, 200200000703, 200200000703, 200200000703, 200200000703), black_n = c(18, 13, 14, 8, 127, 30, 9, 17, 30, 12, 6, 5, 0, 37, 57, 19, 22, 27, 24, 44, 25, 63, 44, 30, 29, 23, 1106, 814, 49, 92, 25, 129, 121, 146, 136, 104, 100, 120, 258, 109, 85, 153, 121, 166, 262, 106, 99, 173, 34, 197), mhwhite_n = c(231, 127, 163, 279, 949, 831, 342, 1561, 2197, 762, 1160, 845, 1147, 1307, 1130, 968, 1341, 1230, 1518, 1081, 1796, 2410, 1551, 1151, 1196, 884, 3498, 4909, 559, 477, 101, 335, 291, 341, 383, 295, 271, 221, 790, 630, 504, 487, 450, 963, 1283, 603, 355, 642, 458, 700), his_n = c(151, 59, 129, 22, 323, 228, 22, 59, 69, 16, 33, 28, 41, 64, 93, 50, 48, 49, 30, 30, 38, 129, 59, 55, 48, 40, 503, 475, 41, 181, 12, 49, 101, 115, 146, 47, 98, 109, 124, 70, 109, 66, 63, 83, 136, 51, 40, 78, 44, 70)), row.names = 0:49, class = "data.frame")

As far as I read, I need to post debunk=FALSE somewhere, but I am not sure where. Thank you in advance Sylwia

mikelove commented 2 years ago

This error isn’t coming from tximport, please post to the other package.