library(maptools)
cmap <- readShapePoly(system.file("maps/CookCensusTracts.shp",package="McSpatial"))
cmap$lnpopdens <- log(cmap$POPULATION/cmap$AREA)
mapplot(cmap,"lnpopdens",sampvar=cmap$AREA>0&cmap$POPULATION>0,col="Blues",
title="Log of Population Density")
Run the code above in your browser using DataLab