The function includes the region itself in its own list of neighbours, and sets attribute "self.included" to TRUE; remove.self reverts the effects of include.self.

include.self(nb)
remove.self(nb)

Arguments

nb

input neighbours list of class nb

Value

The function returns an object of class nb with a list of integer vectors containing neighbour region number ids; attribute "self.included" is set to TRUE.

Author

Roger Bivand Roger.Bivand@nhh.no

See also

Examples

columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- coordinates(as(columbus, "Spatial"))
summary(col.gal.nb, coords)
#> Neighbour list object:
#> Number of regions: 49 
#> Number of nonzero links: 230 
#> Percentage nonzero weights: 9.579342 
#> Average number of links: 4.693878 
#> Link number distribution:
#> 
#>  2  3  4  5  6  7  8  9 10 
#>  7  7 13  4  9  6  1  1  1 
#> 7 least connected regions:
#> 1 6 31 39 42 46 47 with 2 links
#> 1 most connected region:
#> 20 with 10 links
#> Summary of link distances:
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>  0.1276  0.3613  0.4566  0.4694  0.5536  0.8924 
#> 
#>   The decimal point is 1 digit(s) to the left of the |
#> 
#>   1 | 3344
#>   1 | 99
#>   2 | 000011333344
#>   2 | 556677779999
#>   3 | 000011222222223344444444
#>   3 | 556666777777888888889999999999
#>   4 | 00001111112233333333334444
#>   4 | 55666666666666777777777788888899
#>   5 | 0011112222222222222233334444
#>   5 | 556666667788
#>   6 | 000000112244
#>   6 | 5577889999
#>   7 | 11112244
#>   7 | 557777
#>   8 | 1144
#>   8 | 55999999
#> 
summary(include.self(col.gal.nb), coords)
#> Neighbour list object:
#> Number of regions: 49 
#> Number of nonzero links: 279 
#> Percentage nonzero weights: 11.62016 
#> Average number of links: 5.693878 
#> Link number distribution:
#> 
#>  3  4  5  6  7  8  9 10 11 
#>  7  7 13  4  9  6  1  1  1 
#> 7 least connected regions:
#> 1 6 31 39 42 46 47 with 3 links
#> 1 most connected region:
#> 20 with 11 links
#> Summary of link distances:
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>  0.0000  0.2576  0.4073  0.3870  0.5232  0.8924 
#> 
#>   The decimal point is 1 digit(s) to the left of the |
#> 
#>   0 | 0000000000000000000000000000000000000000000000000
#>   0 | 
#>   1 | 3344
#>   1 | 99
#>   2 | 000011333344
#>   2 | 556677779999
#>   3 | 000011222222223344444444
#>   3 | 556666777777888888889999999999
#>   4 | 00001111112233333333334444
#>   4 | 55666666666666777777777788888899
#>   5 | 0011112222222222222233334444
#>   5 | 556666667788
#>   6 | 000000112244
#>   6 | 5577889999
#>   7 | 11112244
#>   7 | 557777
#>   8 | 1144
#>   8 | 55999999
#> 
summary(remove.self(include.self(col.gal.nb)), coords)
#> Neighbour list object:
#> Number of regions: 49 
#> Number of nonzero links: 230 
#> Percentage nonzero weights: 9.579342 
#> Average number of links: 4.693878 
#> Link number distribution:
#> 
#>  2  3  4  5  6  7  8  9 10 
#>  7  7 13  4  9  6  1  1  1 
#> 7 least connected regions:
#> 1 6 31 39 42 46 47 with 2 links
#> 1 most connected region:
#> 20 with 10 links
#> Summary of link distances:
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>  0.1276  0.3613  0.4566  0.4694  0.5536  0.8924 
#> 
#>   The decimal point is 1 digit(s) to the left of the |
#> 
#>   1 | 3344
#>   1 | 99
#>   2 | 000011333344
#>   2 | 556677779999
#>   3 | 000011222222223344444444
#>   3 | 556666777777888888889999999999
#>   4 | 00001111112233333333334444
#>   4 | 55666666666666777777777788888899
#>   5 | 0011112222222222222233334444
#>   5 | 556666667788
#>   6 | 000000112244
#>   6 | 5577889999
#>   7 | 11112244
#>   7 | 557777
#>   8 | 1144
#>   8 | 55999999
#>