R/get.neighbor.R

Defines functions get.neighbor

Documented in get.neighbor

get.neighbor <- function(map, regions)
{
   if(! inherits(map, "gra"))
      stop("Argument 'map' is not an object of class 'gra'!")

   districts <- rownames(map)

   neighbors <- list(length=length(regions))
   for(i in 1:length(regions)){
      ind <- which(districts == regions[i])  
      neighbors[[i]] <- districts[map[ind,] == -1]
   }
   
   names(neighbors) <- regions
   return(neighbors)
}

Try the R2BayesX package in your browser

Any scripts or data that you put into this service are public.

R2BayesX documentation built on Oct. 20, 2023, 9:11 a.m.