#read the shapefile
#display first five rows of shapefile dataset
#plot the shapefile boundaries
usMap <- sf::as_Spatial(sf::st_read(system.file("shapes/usMap.shp", package="mapStats")[1]))
head(usMap@data)
# plot the outlines of the shapefile only
sp::plot(usMap)
# plot map colored according to one of the variables in @data
sp::spplot(usMap, zcol="A187_1")
Run the code above in your browser using DataLab