[R] Plot by FIPS Code using Shapefiles
Roger.Bivand at nhh.no
Wed May 6 12:23:58 CEST 2015
Corey Sparks <corey.sparks <at> utsa.edu> writes:
> Joining data the way you're doing it is dangerous, Roger Bivand and others
> describes a standard way to do this process here:
Quite right - the chunks Corey is referring to are:
Please do refer to the vignette in the maptools package, and to previous
threads which have advised that merge() should not be used, and that the
row.names of the data frames be used as ID keys. Typically using match() on
the row.names of the two objects will show which are not correctly aligned.
Beware that the data from the objects may be jumbled - never use merge,
always use match() on the row.names vectors of the objects to ensure that
the key-IDs agree. Jumbled data happens, it is important not to think
"shapefile" but to think DBMS with the ID key your way of staying sane.
The maptools vignette is at:
Here I also suspect that you'll find that there are non-unique FIPS in the
county polygons file, so may need to go through
> And I do an example using US Census data here, using merge():
> look at page 134 of that pdf.
> Hope this helps
> Corey Sparks, PhD
> Assistant Professor
> Department of Demography
> University of Texas at San Antonio
> 501 West César E. Chávez Blvd
> Monterey Building 2.270C
> San Antonio, TX 78207
> corey.sparks 'at' utsa.edu
> View this message in context:
> Sent from the R help mailing list archive at Nabble.com.
> R-help <at> r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help