<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Choropleths in R (yes, &quot;choropleths&quot;)</title>
	<atom:link href="http://www.thisisthegreenroom.com/2009/choropleths-in-r/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/</link>
	<description>in stereo where available</description>
	<lastBuildDate>Sun, 05 Feb 2012 19:56:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Damian</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-9294</link>
		<dc:creator>Damian</dc:creator>
		<pubDate>Fri, 11 Mar 2011 01:28:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-9294</guid>
		<description>I&#039;m having trouble with this line, as well. It returns the following error:
Error in `[.default`(xj, i) : invalid subscript type &#039;list&#039;

Any tips?</description>
		<content:encoded><![CDATA[<p>I'm having trouble with this line, as well. It returns the following error:<br />
Error in `[.default`(xj, i) : invalid subscript type 'list'</p>
<p>Any tips?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Quora</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-9047</link>
		<dc:creator>Quora</dc:creator>
		<pubDate>Fri, 04 Mar 2011 06:29:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-9047</guid>
		<description>&lt;strong&gt;What is the easiest way to make a state-by-state choropleth map from data in a .csv?...&lt;/strong&gt;

I&#039;d be interested in using whatever method does this the easiest. Ideally, I&#039;d like to modify an SVG somehow and then import it into illustrator to pretty it up, but I&#039;d be content with using something like polymaps to do so. I am struggling to find...</description>
		<content:encoded><![CDATA[<p><strong>What is the easiest way to make a state-by-state choropleth map from data in a .csv?...</strong></p>
<p>I'd be interested in using whatever method does this the easiest. Ideally, I'd like to modify an SVG somehow and then import it into illustrator to pretty it up, but I'd be content with using something like polymaps to do so. I am struggling to find...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miriam</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-8733</link>
		<dc:creator>Miriam</dc:creator>
		<pubDate>Wed, 23 Feb 2011 05:50:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-8733</guid>
		<description>Sorry! For some reason, part of my post was chopped. 
The line I am stumbling over is:

&quot;states &lt;- as.character(stateAbbr[states,2])&quot;

from the previous line I obtain for &quot;states&quot; something like this (this is the first entry):

&#039;states[1]
Autauga County, AL
“AL”&#039;

What does &quot;stateAbbr[states,2]&quot; do, then?

Thank you so much!</description>
		<content:encoded><![CDATA[<p>Sorry! For some reason, part of my post was chopped.<br />
The line I am stumbling over is:</p>
<p>"states &lt;- as.character(stateAbbr[states,2])&quot;</p>
<p>from the previous line I obtain for &quot;states&quot; something like this (this is the first entry):</p>
<p>&#039;states[1]<br />
Autauga County, AL<br />
“AL”&#039;</p>
<p>What does &quot;stateAbbr[states,2]&quot; do, then?</p>
<p>Thank you so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miriam</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-8732</link>
		<dc:creator>Miriam</dc:creator>
		<pubDate>Wed, 23 Feb 2011 05:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-8732</guid>
		<description>Hello!

I am trying to replicate your awesome graph, and I think I have almost everything working except this one line:

&#039;states  states[1]
 Autauga County, AL 
               &quot;AL&quot; 
)

Thank You!</description>
		<content:encoded><![CDATA[<p>Hello!</p>
<p>I am trying to replicate your awesome graph, and I think I have almost everything working except this one line:</p>
<p>'states  states[1]<br />
 Autauga County, AL<br />
               "AL"<br />
)</p>
<p>Thank You!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thomas</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-8648</link>
		<dc:creator>thomas</dc:creator>
		<pubDate>Sat, 19 Feb 2011 14:01:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-8648</guid>
		<description>found it. came from me forgetting to order the code, this line:
mergedata &lt;- mergedata[order(mergedata$order),]

although i don&#039;t understand why not running it would lead to white gaps?</description>
		<content:encoded><![CDATA[<p>found it. came from me forgetting to order the code, this line:<br />
mergedata &lt;- mergedata[order(mergedata$order),]</p>
<p>although i don&#039;t understand why not running it would lead to white gaps?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thomas</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-8631</link>
		<dc:creator>thomas</dc:creator>
		<pubDate>Sat, 19 Feb 2011 01:16:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-8631</guid>
		<description>hi,
i tried your code with my own data, but only on state level. Code works well and is truly easy but for whatever reason, some white area is visible in certain states. if you look at california  .... http://img39.imageshack.us/i/65881540.jpg/ 
any idea what causes that? appreciated ;)</description>
		<content:encoded><![CDATA[<p>hi,<br />
i tried your code with my own data, but only on state level. Code works well and is truly easy but for whatever reason, some white area is visible in certain states. if you look at california  .... <a href="http://img39.imageshack.us/i/65881540.jpg/" rel="nofollow">http://img39.imageshack.us/i/65881540.jpg/</a><br />
any idea what causes that? appreciated <img src='http://thisisthegreenroom.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-3366</link>
		<dc:creator>J</dc:creator>
		<pubDate>Sun, 03 Oct 2010 15:56:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-3366</guid>
		<description>Hi Jon -- I&#039;m pretty sure there is a way to export the contours of the map as a series of lat/long coordinates (though I can&#039;t say off the bat how). You could pair that data with a z-variable to create the 3D graph. I would be remiss if I didn&#039;t caution that 3D charts are frequently more about eye-candy and less about information; make sure that the move to 3D actually imparts greater meaning in addition to looking cool.

Please let us know if it works!</description>
		<content:encoded><![CDATA[<p>Hi Jon -- I'm pretty sure there is a way to export the contours of the map as a series of lat/long coordinates (though I can't say off the bat how). You could pair that data with a z-variable to create the 3D graph. I would be remiss if I didn't caution that 3D charts are frequently more about eye-candy and less about information; make sure that the move to 3D actually imparts greater meaning in addition to looking cool.</p>
<p>Please let us know if it works!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jonmcrawford</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-3351</link>
		<dc:creator>jonmcrawford</dc:creator>
		<pubDate>Sat, 02 Oct 2010 12:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-3351</guid>
		<description>I was wondering if you could start with this type of data, then transform the plots into the persp() package to create a prism map? (intensity would not be just by color, but then elevation of the county in the image, with a consistent z-value for the entire county)

Not sure if that would work, but I was going to play around with that.</description>
		<content:encoded><![CDATA[<p>I was wondering if you could start with this type of data, then transform the plots into the persp() package to create a prism map? (intensity would not be just by color, but then elevation of the county in the image, with a consistent z-value for the entire county)</p>
<p>Not sure if that would work, but I was going to play around with that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-2675</link>
		<dc:creator>Matthew</dc:creator>
		<pubDate>Fri, 16 Jul 2010 07:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-2675</guid>
		<description>Hi,
With respect to adding Hawaii and Alaska: Why not transform the latittude and and longitude values describing their boundaries so they are situated south of the mainland states as per Nathan&#039;s map?
Nice work by the way.
Cheers

Matt Legge</description>
		<content:encoded><![CDATA[<p>Hi,<br />
With respect to adding Hawaii and Alaska: Why not transform the latittude and and longitude values describing their boundaries so they are situated south of the mainland states as per Nathan's map?<br />
Nice work by the way.<br />
Cheers</p>
<p>Matt Legge</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-2560</link>
		<dc:creator>J</dc:creator>
		<pubDate>Wed, 09 Jun 2010 13:53:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-2560</guid>
		<description>Hi Clem - 
Sorry for the confusion. I guess my code isn&#039;t quite as self-contained as I had thought.

&quot;state abbr.csv&quot; is a simple file I created to provide a mapping between state names and state abbreviations -- as I recall, the data format and the necessary format in R were not the same. The file looked like this: New Jersey &#124; NJ &#124;&#124; New Mexico &#124; NM &#124;&#124; New York &#124; NY &#124;&#124; ... etc. A very simple translation from one set of data into another.

&quot;unemp_data&quot; is my [unemp]loyment [data]set. To have R do any useful plotting, the plotted object needs to contain all plotted attributes -- it&#039;s very hard to overlay multiple objects intelligently. So, my main dataset needs to contain not just the data to be plotted, but extraneous items like the colors I want to plot in as well (note there are ways around this if you are willing to let R pick colors on your behalf). In this specific line, I am using the cut function to define &quot;breaks&quot; in the unemployment data of 2% width, capped at 100% to fill out the last bucket. So a level of 3% would be in one bucket and a level of 6% would be in another bucket. I convert those buckets to numbers (again, I don&#039;t remember exactly why but most likely just as a data integrity step) and then to factors, which tells R to consider each value a distinct &quot;level&quot;. In other words, it won&#039;t think of 1,2,3,4 as a continuous spectrum in which &quot;2&quot; is near &quot;3&quot; but far from &quot;4&quot;; rather, it will think of each number as a &quot;level&quot; and there is no relationship between &quot;2&quot; and &quot;3&quot; that implies greater similarity than between &quot;2&quot; and &quot;4&quot;. Finally, I store my color factors  in the dataset&#039;s colorBuckets column. Later, I tell the plotting functions to give each of those buckets a different color, which I also specify.</description>
		<content:encoded><![CDATA[<p>Hi Clem -<br />
Sorry for the confusion. I guess my code isn't quite as self-contained as I had thought.</p>
<p>"state abbr.csv" is a simple file I created to provide a mapping between state names and state abbreviations -- as I recall, the data format and the necessary format in R were not the same. The file looked like this: New Jersey | NJ || New Mexico | NM || New York | NY || ... etc. A very simple translation from one set of data into another.</p>
<p>"unemp_data" is my [unemp]loyment [data]set. To have R do any useful plotting, the plotted object needs to contain all plotted attributes -- it's very hard to overlay multiple objects intelligently. So, my main dataset needs to contain not just the data to be plotted, but extraneous items like the colors I want to plot in as well (note there are ways around this if you are willing to let R pick colors on your behalf). In this specific line, I am using the cut function to define "breaks" in the unemployment data of 2% width, capped at 100% to fill out the last bucket. So a level of 3% would be in one bucket and a level of 6% would be in another bucket. I convert those buckets to numbers (again, I don't remember exactly why but most likely just as a data integrity step) and then to factors, which tells R to consider each value a distinct "level". In other words, it won't think of 1,2,3,4 as a continuous spectrum in which "2" is near "3" but far from "4"; rather, it will think of each number as a "level" and there is no relationship between "2" and "3" that implies greater similarity than between "2" and "4". Finally, I store my color factors  in the dataset's colorBuckets column. Later, I tell the plotting functions to give each of those buckets a different color, which I also specify.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clem</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-2552</link>
		<dc:creator>Clem</dc:creator>
		<pubDate>Tue, 08 Jun 2010 12:23:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-2552</guid>
		<description>Hi, 
I am trying to use your code to do a similar map of the US by county of the mortality rate caused by colon cancer. I am not a pro at R therefore i have a few question about your code. 
how or where did you get the file &quot;state abbr.csv&quot; ?
And could briefly explain this line of code not sure i understand what &quot;unemp&quot; is 

unemp_data$colorBuckets &lt;- as.factor(as.numeric(cut(unemp_data$unemp,c(0,2,4,6,8,10,100))))

Thank you and great post extremely useful</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I am trying to use your code to do a similar map of the US by county of the mortality rate caused by colon cancer. I am not a pro at R therefore i have a few question about your code.<br />
how or where did you get the file "state abbr.csv" ?<br />
And could briefly explain this line of code not sure i understand what "unemp" is </p>
<p>unemp_data$colorBuckets &lt;- as.factor(as.numeric(cut(unemp_data$unemp,c(0,2,4,6,8,10,100))))</p>
<p>Thank you and great post extremely useful</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iPhone Simulator causes package installation to hang on OS X - As Yet Unclassified</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-2390</link>
		<dc:creator>iPhone Simulator causes package installation to hang on OS X - As Yet Unclassified</dc:creator>
		<pubDate>Thu, 18 Mar 2010 22:51:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-2390</guid>
		<description>[...] programming language. I&#8217;d heard of it in passing, but hadn&#8217;t tried it. After seeing how cool maps could be generated with very little code, I decided to try it [...]</description>
		<content:encoded><![CDATA[<p>[...] programming language. I&#8217;d heard of it in passing, but hadn&#8217;t tried it. After seeing how cool maps could be generated with very little code, I decided to try it [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-1622</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Sat, 14 Nov 2009 13:20:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-1622</guid>
		<description>I tried doing this a few months ago in python, got lazy and found this
http://www.sacmeq.org/statplanet/
Its all done in excel which makes it easy. Gives you a time scale on the bottom too.</description>
		<content:encoded><![CDATA[<p>I tried doing this a few months ago in python, got lazy and found this<br />
<a href="http://www.sacmeq.org/statplanet/" rel="nofollow">http://www.sacmeq.org/statplanet/</a><br />
Its all done in excel which makes it easy. Gives you a time scale on the bottom too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-1615</link>
		<dc:creator>J</dc:creator>
		<pubDate>Fri, 13 Nov 2009 05:23:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-1615</guid>
		<description>Hadley - I was about to say thanks, because through you I discovered the embeddable code templates that I used here, but I just realized that I owe you much more because ggplot2 is actually &lt;a href=&quot;http://had.co.nz/&quot; rel=&quot;nofollow&quot;&gt;yours&lt;/a&gt;! Knowing that, I&#039;m not sure a simple thanks would do - it really is a phenomenal package (and I think I&#039;m going to become its newest evangelist).</description>
		<content:encoded><![CDATA[<p>Hadley - I was about to say thanks, because through you I discovered the embeddable code templates that I used here, but I just realized that I owe you much more because ggplot2 is actually <a href="http://had.co.nz/" rel="nofollow">yours</a>! Knowing that, I'm not sure a simple thanks would do - it really is a phenomenal package (and I think I'm going to become its newest evangelist).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hadley</title>
		<link>http://www.thisisthegreenroom.com/2009/choropleths-in-r/comment-page-1/#comment-1614</link>
		<dc:creator>Hadley</dc:creator>
		<pubDate>Fri, 13 Nov 2009 04:21:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.thisisthegreenroom.com/?p=3123#comment-1614</guid>
		<description>I think the maps package does some thinning (generalisation) of the data which results in a slightly nicer appearance.  I think if you look at the tip of Michigan, you can see a small difference between the state and county boundaries when you do this. I have some draft code to do this for general polygons, but it&#039;s very hard to do it in a topologically consistent manner.  

Nice plots :)</description>
		<content:encoded><![CDATA[<p>I think the maps package does some thinning (generalisation) of the data which results in a slightly nicer appearance.  I think if you look at the tip of Michigan, you can see a small difference between the state and county boundaries when you do this. I have some draft code to do this for general polygons, but it's very hard to do it in a topologically consistent manner.  </p>
<p>Nice plots <img src='http://thisisthegreenroom.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

