I have a SpatialPolygonsDataFrame that comes from the UScensus2010 package. I am trying to create a choropleth. When I do so, this works as expected:
data(colorado.county10)
choropleth(colorado.county10,
"P0010001",
color = list(fun = "rainbow",
attr = list(4)),
main="2010 US Counties",
type="plot",
border="black")
but this fails due to 'P0010001' not being found
data(colorado.county10)
ggplot(colorado.county10, aes(long, lat, group = group)) +
geom_polygon(aes(fill = P0010001), colour = alpha("white", 1/2), size = 0.2) +
scale_fill_brewer(pal = "PuRd")
As I've tried to figure this out, I've noted that colorado.county10$P0010001 returns an array of numbers, but colorado.county10[,"P0010001"] returns a SpatialPolygonsDataFrame.
Any insights into what is happening?