<div dir="ltr"><div class="gmail_default" style><font face="verdana, sans-serif">Hello, José luis!</font></div><div class="gmail_default" style><font face="verdana, sans-serif"><br></font></div><div class="gmail_default" style><font face="verdana, sans-serif">I ran your code, but I did not notice the error reported. It's working fine for me.</font><br></div><div class="gmail_default" style><font face="verdana, sans-serif"><br></font></div><div class="gmail_default" style><font face="verdana, sans-serif">sessionInfo()</font></div><div class="gmail_default" style><font face="verdana, sans-serif"><div class="gmail_default">R version 3.1.3 (2015-03-09)</div><div class="gmail_default">Platform: x86_64-w64-mingw32/x64 (64-bit)</div><div class="gmail_default">Running under: Windows 8 x64 (build 9200)</div><div class="gmail_default"><br></div><div class="gmail_default">locale:</div><div class="gmail_default">[1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 LC_MONETARY=Portuguese_Brazil.1252</div><div class="gmail_default">[4] LC_NUMERIC=C LC_TIME=Portuguese_Brazil.1252 </div><div class="gmail_default"><br></div><div class="gmail_default">attached base packages:</div><div class="gmail_default">[1] stats graphics grDevices utils datasets methods base </div><div class="gmail_default"><br></div><div class="gmail_default">other attached packages:</div><div class="gmail_default">[1] mapproj_1.2-2 maps_2.3-9 </div><div class="gmail_default"><br></div><div class="gmail_default">loaded via a namespace (and not attached):</div><div class="gmail_default">[1] tools_3.1.3</div></font></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="arial, helvetica, sans-serif" style="font-size:small"><div style="font-family:'trebuchet ms',sans-serif;display:inline"></div>================================================<br>Éder Comunello</font><div style="font-size:small"><span style="font-family:arial,helvetica,sans-serif">PhD Student in Agricultural Systems Engineering (USP/Esalq)</span><br></div><div><span style="font-size:small">Brazilian Agricultural Research Corporation (</span><font face="arial, helvetica, sans-serif" style="font-size:small">Embrapa)</font><div style="font-size:small"><font face="arial, helvetica, sans-serif">Dourados, MS, Brazil [</font>22 16.5'S, 54 49.0'W<span style="font-family:arial,helvetica,sans-serif">]</span></div><div><div><br></div><div><br></div></div><div style="font-size:small"><img src="cid:ii_ia0xpvbp0_14d80778362ec107" width="519" height="332"><br><br></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">2015-05-22 12:16 GMT-04:00 José Luis Rotundo <span dir="ltr"><<a href="mailto:rotundo.jose@gmail.com" target="_blank">rotundo.jose@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Dear List,<br>
<br>
I want to plot a US county level map with counties colored according a<br>
categorical variable. I was successful for the most part, but when<br>
trying to add state level borders, to make the map look better, the<br>
borders do not follow the geographical limits.<br>
<br>
Here is the link to the map I ended up with: <a href="http://imgur.com/UqcpVBW" target="_blank">http://imgur.com/UqcpVBW</a><br>
<br>
If you want to reproduce the what I am doing, the data is here:<br>
<a href="http://www.filedropper.com/data_4" target="_blank">http://www.filedropper.com/data_4</a><br>
<br>
Below is the code I am using.<br>
<br>
Thanks a lot in advance for any help to solve this problem.<br>
<br>
José L. Rotundo<br>
CONICET<br>
Facultad de Ciencias Agrarias<br>
Univ. Nacional de Rosario<br>
Zavalla, Santa Fe<br>
Argentina<br>
<br>
#############################################################<br>
# Pick the colors for the categorical values<br>
colors = c("#CC0000", "#FF9999", "#E0E0E0", "#99FF99", "#00CC00")<br>
<br>
#Creates a new variable with the categories.<br>
data$colorBuckets <- as.numeric(cut(data$Slope, c(-0.30, -0.20, -0.10, 0.10,<br>
0.20, 0.30)))<br>
<br>
# Put a 3 (equivalent to slope 0) when there is NA's<br>
data$colorBuckets[<a href="http://is.na" target="_blank">is.na</a>(data$colorBuckets)] <- 3<br>
<br>
# Matches the values of FIPS with the color categories<br>
colorsmatched <- data$colorBuckets<br>
<br>
library(mapproj)<br>
# Map colored counties according the categories<br>
map("county", col = colors[colorsmatched], fill = TRUE, resolution = 0,<br>
lty = 0, projection = "polyconic")<br>
<br>
# Add border around each county<br>
map("county", col = "gray", fill = FALSE, add = TRUE, lty = 1, lwd = 0.2,<br>
projection = "polyconic")<br>
<br>
# Add border to each state (THIS IS THE PROBLEMATIC STEP)<br>
map("state", col = "black", fill = FALSE, add = TRUE, lty = 1, lwd = 0.4,<br>
projection = "polyconic")<br>
<br>
################################################################<br>
<br>
_______________________________________________<br>
R-sig-Geo mailing list<br>
<a href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br>
<a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>
</blockquote></div><br></div></div>