Skip to content

Choropleth values plotting incorrectly

2 messages · Justine Sumrok, Roger Bivand

#
On Fri, 19 Jul 2013, Justine Sumrok wrote:

            
Thanks for example data. Never use merge(), it always masks trouble. Never 
assign directly to the data slot, always use spCbind() in maptools. You 
have multiple problems. You have 616 entities in your shapefile, but only 
601 of these are in the CSV file (which has 768 observations) - this based 
on using match() on character representations of NCESID - it is a factor 
in OH, but integer in dist. So you have a two-way matching problem. You 
can maybe address it by first removing the 15 entities from OH for which 
you have no data, then dropping from dist the IDs that do not match, and 
finally spCbind() after checking that row.names(OH) and row.names(dist) 
agree. I started by:

row.names(OH) <- as.character(OH$NCESID)
dist$NCESID <- as.character(dist$NCESID)
row.names(dist) <- dist$NCESID

to remove the possibility that the different representations were getting 
in the way. I don't know what you'll choose to do with the IDs in OH foe 
which you have no data, so I'll leave this here for now.

See the vignette("combine_maptools") in maptools for more ideas.

Hope this helps,

Roger