View source: R/localmoran.map.R
localmoran.map | R Documentation |
This function plots a map with the results of local Moran's I statistics, based on spatial polygons, a 'listw' object, and a variable with an ID.
localmoran.map(p, listw, VAR, by)
p |
A simple features 'sf' object |
listw |
A listw object (see spdep) |
VAR |
A character string with the name of a variable |
by |
A character string with the name of a key to join the local Moran's I statistics to the 'sf' object |
# Create a map of local Moran's I statistics for population density
#
# Obtain a listw object for the contiguities. First obtain the neighbors:
Hamilton_CT.nb <- spdep::poly2nb(as(Hamilton_CT, "Spatial"))
# Based on the neighbors, obtain a listw object:
Hamilton_CT.w <- spdep::nb2listw(Hamilton_CT.nb)
localmoran.map(Hamilton_CT, Hamilton_CT.w, "POP_DENSITY", "TRACT")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.