data(oldcol)
HICRIME <- cut(COL.OLD$CRIME, breaks=c(0,35,80), labels=c("low","high"))
names(HICRIME) <- rownames(COL.OLD)
joincount.multi(HICRIME, nb2listw(COL.nb, style="B"))
## Not run:
# data(hopkins)
# image(1:32, 1:32, hopkins[5:36,36:5], breaks=c(-0.5, 3.5, 20),
# col=c("white", "black"))
# box()
# hopkins.rook.nb <- cell2nb(32, 32, type="rook")
# unlist(spweights.constants(nb2listw(hopkins.rook.nb, style="B")))
# hopkins.queen.nb <- cell2nb(32, 32, type="queen")
# hopkins.bishop.nb <- diffnb(hopkins.rook.nb, hopkins.queen.nb, verbose=FALSE)
# hopkins4 <- hopkins[5:36,36:5]
# hopkins4[which(hopkins4 > 3, arr.ind=TRUE)] <- 4
# hopkins4.f <- factor(hopkins4)
# table(hopkins4.f)
# joincount.multi(hopkins4.f, nb2listw(hopkins.rook.nb, style="B"))
# cat("replicates Upton & Fingleton table 3.4 (p. 166)\n")
# joincount.multi(hopkins4.f, nb2listw(hopkins.bishop.nb, style="B"))
# cat("replicates Upton & Fingleton table 3.6 (p. 168)\n")
# joincount.multi(hopkins4.f, nb2listw(hopkins.queen.nb, style="B"))
# cat("replicates Upton & Fingleton table 3.7 (p. 169)\n")
# ## End(Not run)
Run the code above in your browser using DataCamp Workspace