Skip to contents

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.

Usage

localmoran.map(p = p, listw = listw, VAR = VAR, by = by)

Arguments

p

A simple features sf object

listw

A listw object (see spdep)

VAR

The name of a variable

by

The name of a key to join the local Moran's I statistics to the sf object

Examples

# Create a map of local Moran's I statistics for population density
#
data(Hamilton_CT)
# Obtain a listw object for the contiguities. First obtain the neighbors:
Hamilton_CT.nb <- spdep::poly2nb(Hamilton_CT)
# 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")
#> Joining with `by = join_by(key, Z)`