#My issue is somewhere is those lines : #====== setwd(".") library(spdep) library(RANN) EU_NUTS <- read.table("./mydata2018.txt") #dataframe of coordinates x and y Coord<-cbind(EU_NUTS$"x",EU_NUTS$"y") #Neighbour objects- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EU_NUTS_kn1 <- knn2nb(knearneigh(Coord, k = 20), row.names =EU_NUTS$NUTS_ID) Kn1list<-nb2listw(EU_NUTS_kn1, glist=NULL, style="W", zero.policy=FALSE) #Loop - - - - - - - - year<-c("X2001","X2002","X2003","X2004","X2005","X2006","X2007","X2008", "X2009","X2010","X2011","X2012","X2013","X2014","X2015","X2016") CLI<-vector("list", length(year)) for(i in 1:length(year)){ print(i) OLS<-lm(log(EU_NUTS[,year[i]])~1+factor(EU_NUTS$NUTS_L1)) CLIi<-localmoran.exact(OLS, nb=EU_NUTS_kn1, style = "S", zero.policy = TRUE, alternative = "greater", spChk = NULL, resfun = residuals, save.Vi = FALSE, useTP=TRUE, truncErr=1e-6, zeroTreat=0.1) CLIi<-data.frame(CLIi) CLI[[i]]<-c(CLI[[i]],CLIi) }