<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>A little bit about R, one day at a time.</description><title>is.R()</title><generator>Tumblr (3.0; @is-r)</generator><link>http://is-r.tumblr.com/</link><item><title>To plot them is my real test</title><description>&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/b1ac333c15415c778ee3f8ee4d637a8b/tumblr_inline_mk9sybrfDU1qz4rgp.png"/&gt;&lt;/p&gt;

&lt;p&gt;I almost couldn&amp;#8217;t bring myself to post this, but it&amp;#8217;s April Fools&amp;#8217; Day, so I&amp;#8217;ll never have a better opportunity.&lt;/p&gt;
&lt;p&gt;This Gist shows how to scrape &amp;#8220;stats&amp;#8221; and .PNG images from, erm, &lt;a href="http://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_base_stats_(Generation_I)"&gt;Bulbapedia&lt;/a&gt;, run a simple dimensionality reduction on those &amp;#8220;stats,&amp;#8221; and plot all 151 original Pokemon.&lt;/p&gt;
&lt;p&gt;I don&amp;#8217;t know much about Pokemon, so I can&amp;#8217;t vouch for the utility of this approach, but perhaps this post will one day be seen as the foundation of &lt;span&gt;the field of Pokemon Studies.&lt;/span&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/dsparks/3883468"&gt;https://gist.github.com/dsparks/3883468&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/46821313005</link><guid>http://is-r.tumblr.com/post/46821313005</guid><pubDate>Mon, 01 Apr 2013 00:00:44 -0400</pubDate><category>rstats</category><category>graphics</category><category>aprilFools</category></item><item><title>MeRRy ChRistmas!</title><description>&lt;p&gt;Merry Christmas is.R() readers! Thanks for accompanying us through an excellent first semester of R blogging, and for your feedback and enthusiasm. To celebrate, we&amp;#8217;ve built an &lt;a href="http://is-r.tumblr.com/post/36805309334/composite-image-mosaics"&gt;image mosaic&lt;/a&gt; from the shiny, happy avatars of our over 600 (!) &lt;a href="https://twitter.com/isDotR/followers"&gt;Twitter followers&lt;/a&gt;.&lt;/p&gt;
&lt;div class="image"&gt;&lt;a href="http://zoom.it/WO8G"&gt;&lt;img align="middle" alt="Click me!" height="353" src="http://www.christmaswow.com/Images/Tree-for-xmas.jpg" width="216"/&gt;&lt;/a&gt;
&lt;div&gt;Click for a &lt;em&gt;beautiful&lt;/em&gt; mosaic!&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;We&amp;#8217;ll be back in 2013 with even more tutorials and unnecessarily contrived examples, and we hope you&amp;#8217;ll continue to visit, &lt;a href="http://www.tumblr.com/ask"&gt;pose hard questions&lt;/a&gt;, and explore R with us.&lt;/p&gt;</description><link>http://is-r.tumblr.com/post/38785547397</link><guid>http://is-r.tumblr.com/post/38785547397</guid><pubDate>Tue, 25 Dec 2012 06:30:47 -0500</pubDate><category>rstats</category></item><item><title>Latent Class Analysis with poLCA</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/7b3b882ed9a175fcc27ce83c58b20378/tumblr_inline_mfadjz886p1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;On an airplane the other day, I learned of a method called latent class (transition) analysis, and it sounded like an interesting thing to try in R. Of course, as with everything R, There is a Package for That, called &lt;a href="http://userwww.service.emory.edu/~dlinzer/poLCA/"&gt;poLCA&lt;/a&gt;, written by none other than &lt;a href="http://userwww.service.emory.edu/~dlinzer/"&gt;Drew Linzer&lt;/a&gt; (of &lt;a href="http://votamatic.org/"&gt;Votamatic&lt;/a&gt; fame) and &lt;a href="http://www.sscnet.ucla.edu/polisci/faculty/lewis/"&gt;Jeffrey Lewis&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I wasn&amp;#8217;t able to think of a good application for transition analysis specifically, but I did use Christopher&amp;#8217;s ANES data to estimate latent &amp;#8220;types&amp;#8221; of respondents. The example model illustrates a four-class model, and I&amp;#8217;ll leave it as an exercise for the interested reader to assign subjective names to each class.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This Gist also attempts to improve on the default plot both by eschewing the 3-D effect, and by putting classes, rather than variables, in direct comparison with one another. Also, for what it&amp;#8217;s worth, the plot code shows how to draw a &lt;a href="http://docs.ggplot2.org/current/geom_bar.html"&gt;bar plot&lt;/a&gt; when you have already computed counts or proportions &amp;#8212; use &lt;/span&gt;&lt;span&gt;stat=&amp;#8221;identity&amp;#8221;&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for celebrating Advent with us, and for your feedback and support. We&amp;#8217;re taking a little break after tomorrow&amp;#8217;s post, but we&amp;#8217;ll be back better than ever next year!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="http://media.tumblr.com/04c778d31045287acc00480db53a3850/tumblr_inline_mfadkbu78S1qz4s35.png"/&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4337992"&gt;https://gist.github.com/4337992&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/38707429332</link><guid>http://is-r.tumblr.com/post/38707429332</guid><pubDate>Mon, 24 Dec 2012 06:30:46 -0500</pubDate><category>rstats</category><category>ggplot2</category><category>reshape2</category><category>poLCA</category><category>AdventCalendaR</category></item><item><title>Measuring the Gerrymander with spatstat</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/9339da3a44887fbb85066d9da295162d/tumblr_inline_mf9r00mqPe1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;Well, to be specific, I mean measuring district compactness (a very interesting subject, see &lt;a href="http://rangevoting.org/YoungCompactness.pdf"&gt;these&lt;/a&gt; &lt;a href="http://www.socsci.uci.edu/~bgrofman/43%20Niemi-Grofman-Carlucci-Hofeller-Measuring%20compactness.pdf"&gt;three&lt;/a&gt; &lt;a href="http://www.udel.edu/johnmack/research/gerrymandering.pdf"&gt;articles&lt;/a&gt; for starters). There are myriad ways of measuring the &amp;#8220;oddness&amp;#8221; of a shape, including a comparison of the area of the district to its &lt;a href="http://en.wikipedia.org/wiki/Circumscribed_circle"&gt;circumcircle&lt;/a&gt;, the moment of inertia of the shape, the probability that a path connecting two random points will pass through the polygon, etc.&lt;/p&gt;
&lt;p&gt;In today&amp;#8217;s Gist, I use the &lt;a href="http://cran.r-project.org/web/packages/spatstat/index.html"&gt;spatstat&lt;/a&gt; package to convert &lt;a href="http://www.census.gov/geo/www/cob/cd110.html#shp"&gt;Congressional district shapefiles&lt;/a&gt; to &lt;a href="http://www.inside-r.org/packages/cran/spatstat/docs/owin.object"&gt;owin objects&lt;/a&gt;, which can be very persnickety &amp;#8212; meaning that for our present purposes I have just skipped over districts with overlapping polygons or other owin conversion obstacles. However, spatstat lets us do neat things with owin objects, including the calculation of the &lt;a href="http://www.inside-r.org/packages/cran/spatstat/docs/area.owin"&gt;area&lt;/a&gt; and &lt;a href="http://www.inside-r.org/packages/cran/spatstat/docs/perimeter"&gt;perimeter&lt;/a&gt; of polygons, which I use to compute and then plot a simple Area / Perimeter ratio measure of district compactness.&lt;/p&gt;
&lt;p&gt;As you can see in the guilty-pleasure Spectral palette choropleth below (click it for a larger view), the least compact districts are unsurprisingly typically found in high-population-density areas. Also, you can use this map to find your way from Greensboro to Charlotte, &lt;a href="http://en.wikipedia.org/wiki/North_Carolina's_12th_congressional_district"&gt;via I-85&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://raw.github.com/dsparks/Test_image/master/District%20compactness%20map.png"&gt;&lt;img src="http://media.tumblr.com/f403d9a4849b73d8efa6ff615d5592fd/tumblr_inline_mf9qtvDOxi1qz4s35.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4335246"&gt;https://gist.github.com/4335246&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/38619550409</link><guid>http://is-r.tumblr.com/post/38619550409</guid><pubDate>Sun, 23 Dec 2012 06:30:37 -0500</pubDate><category>rstats</category><category>maptools</category><category>rgdal</category><category>ggplot2</category><category>spatstat</category><category>RColorBrewer</category><category>AdventCalendaR</category></item><item><title>The definitive guide to plotting confidence intervals in R</title><description>&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/9aca4a9fba23cff3a13e3a886393e9d3/tumblr_inline_mf8zwnaWnq1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;Here at is.R(), we have produced countless posts that &lt;a href="http://is-r.tumblr.com/post/33765462561/the-distribution-of-ideology-in-the-u-s-house-with"&gt;feature&lt;/a&gt; &lt;a href="http://is-r.tumblr.com/post/34628702940/ggtutorial-day-2-grid-arrange"&gt;plots&lt;/a&gt; &lt;a href="http://is-r.tumblr.com/post/35266021903/five-thirty-hate"&gt;with&lt;/a&gt; &lt;a href="http://is-r.tumblr.com/post/37547995110/handling-missing-data-with-amelia"&gt;confidence&lt;/a&gt; &lt;a href="http://is-r.tumblr.com/post/38055963968/possibly-slightly-better-text-analysis-with-lme4"&gt;intervals&lt;/a&gt;, but apparently none of those are easy to find with Google. So, today, for the purposes of &lt;a href="http://en.wikipedia.org/wiki/Search_engine_optimization"&gt;SEO&lt;/a&gt;, we&amp;#8217;ve put &amp;#8220;plotting confidence intervals&amp;#8221; in the title of our post.&lt;/p&gt;
&lt;p&gt;We also cannot resist an earnest plea from our &lt;a href="http://www.poliscijobrumors.com/topic.php?id=74188"&gt;Political Science colleagues&lt;/a&gt;, who managed to find our &lt;a href="http://is-r.tumblr.com/ask"&gt;Ask us anything&lt;/a&gt; page, and whom we would hate to disappoint. It is worth mentioning that there are &lt;a href="http://www.carlislerainey.com/2012/06/30/coefficient-plots-in-r/"&gt;some&lt;/a&gt; &lt;a href="http://www.carlislerainey.com/2012/07/03/an-improvement-to-coefficient-plots/"&gt;alternatives&lt;/a&gt; to, and &lt;a href="http://www.carlislerainey.com/2012/07/06/why-i-dont-like-coefficient-plots/"&gt;critiques&lt;/a&gt; of, this particular style of coefficient plot, and we may return to the subject at a later date.&lt;/p&gt;
&lt;p&gt;But, for representing an arbitrary number of confidence intervals from an arbitrary number of models, this code should work:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/6ab4ab00944b7d51592de76f1143c86e/tumblr_inline_mf9095GLgj1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4332698"&gt;https://gist.github.com/4332698&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/38538981197</link><guid>http://is-r.tumblr.com/post/38538981197</guid><pubDate>Sat, 22 Dec 2012 07:34:49 -0500</pubDate><category>rstats</category><category>ggplot2</category><category>coefficientPlot</category><category>AdventCalendaR</category></item><item><title>Beautiful network diagrams with ggplot2</title><description>&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/9ffa6892fe792cadd3dd3e9f78c9fd37/tumblr_inline_mf8r7zHtwu1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;I don&amp;#8217;t usually like describing my own work as &amp;#8220;beautiful,&amp;#8221; but with your permission I will make an exception today. There have been some &lt;a href="http://is-r.tumblr.com/ask"&gt;requests&lt;/a&gt; for scripts illustrating the plotting of network diagrams with ggplot2, and today (for the &lt;a href="http://en.wikipedia.org/wiki/Winter_solstice"&gt;winter solstice&lt;/a&gt;) we&amp;#8217;re bringing you a really nice-looking way of doing just that.&lt;/p&gt;
&lt;p&gt;In fact, this Gist implements several features that are novel to R, inspired by &lt;a href="http://www.win.tue.nl/~dholten/papers/directed_edges_chi.pdf"&gt;this excellent user study&lt;/a&gt; on visualizing directed edges in graphs. The code is written to allow the use of &amp;#8220;tapered-intensity-curved&amp;#8221; edges between nodes (see Figure 10 of the linked Holten and Wijk paper), which were found to be significantly better than the standard arrow representation in a simple graph interpretation task.&lt;/p&gt;
&lt;p&gt;It is easy to &amp;#8220;turn off&amp;#8221; any of these three attributes (taper, intensity, curve), either through the workhorse edgeMaker() function defined in the script, or in the plot code itself. I don&amp;#8217;t think the code for applying curve to edges is as good as it could be, so if you have any suggestions, please drop us a line at &lt;a href="http://twitter.com/isDotR"&gt;@isDotR&lt;/a&gt;. Also note that edge direction should be read from/to::wide//narrow::dark/light, like the beak of an &lt;a href="http://en.wikipedia.org/wiki/Ibis"&gt;ibis&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I think these graphs are actually quite beautiful, not only aesthetically, but as an illustration of the manner in which R allows us to stand on the shoulders of great package (&lt;a href="http://cran.r-project.org/web/packages/sna/"&gt;sna&lt;/a&gt;, &lt;a href="http://cran.r-project.org/web/packages/igraph/"&gt;igraph&lt;/a&gt;, &lt;a href="http://cran.r-project.org/web/packages/ggplot2/"&gt;ggplot2&lt;/a&gt;, &lt;a href="http://cran.r-project.org/web/packages/Hmisc/"&gt;Hmisc&lt;/a&gt;) authors, and succinctly put together a very elegant finished product:&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/9ad7e2a8d5a73451389df1e4d8f8411a/tumblr_inline_mf8r38ptTd1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4331058"&gt;https://gist.github.com/4331058&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/38459242505</link><guid>http://is-r.tumblr.com/post/38459242505</guid><pubDate>Fri, 21 Dec 2012 07:16:53 -0500</pubDate><category>rstats</category><category>sna</category><category>igraph</category><category>ggplot2</category><category>Hmisc</category><category>reshape2</category><category>AdventCalendaR</category></item><item><title>Geocoding location data with dismo</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/2c94d3f41aaded8fcafcf112140f00e7/tumblr_inline_mf8l82Outu1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;Today&amp;#8217;s Gist could actually end up being very useful to a number of you. It&amp;#8217;s something of a trumped-up example, but it illustrates in very simple code how to do three interesting things:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Gather Tweets by search term (&lt;a href="http://is-r.tumblr.com/post/37468761327/evaluating-term-popularity-with-twitter"&gt;which we&amp;#8217;ve done before&lt;/a&gt;), and look up user info for each of the users returned by that search.&lt;/li&gt;
&lt;li&gt;Convert textual user location data to approximate latitude &amp;amp; longitude coordinates with the &lt;a href="https://developers.google.com/maps/documentation/geocoding/"&gt;Google geocoding web-service&lt;/a&gt;, using a single function, &lt;a href="http://www.inside-r.org/packages/cran/dismo/docs/geocode"&gt;geocode()&lt;/a&gt;, from the &lt;a href="http://cran.r-project.org/web/packages/dismo/"&gt;dismo&lt;/a&gt; package. This is a revelation to me, and though there appears to be a daily rate limit, I can imagine so many applications for which this would be useful.&lt;/li&gt;
&lt;li&gt;Very easily plot a world map (albeit with a lame projection), and superimpose points indicating the inferred location of #rstats-Tweeting users.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;And all in just 29 (+/-) lines. Truly, truly, we are living in a great era for statistical computing.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/fe04809aa086e207f0caf7f9f1235513/tumblr_inline_mf8l8uQCfM1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4329876"&gt;https://gist.github.com/4329876&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/38377477634</link><guid>http://is-r.tumblr.com/post/38377477634</guid><pubDate>Thu, 20 Dec 2012 06:52:41 -0500</pubDate><category>rstats</category><category>twitteR</category><category>dismo</category><category>maps</category><category>ggplot2</category><category>AdventCalendaR</category></item><item><title>Finding Numeric Values of Strings using strsplit()</title><description>&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_mf6n95CB6T1rwydv6.png"/&gt;&lt;/p&gt;
&lt;p&gt;Given a random list of words, can you find which has the lowest or highest numerical value when we apply a basic number:letter cipher? &lt;/p&gt;
&lt;p&gt;A while back I asked David how he would solve this problem: &lt;/p&gt;
&lt;p&gt;&lt;a href="http://projecteuler.net/problem=42"&gt;http://projecteuler.net/problem=42&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Today&amp;#8217;s post shows how to take a vector of words, parse them into each of the individual letters comprising the word, and calculate the sum of the value of the word using A=1, B=2, &amp;#8230;, Z=26.&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
&lt;p&gt;P.S. The code can be modified to find the answer (162) to: &lt;/p&gt;
&lt;p&gt;&lt;a href="http://projecteuler.net/problem=42"&gt;http://projecteuler.net/problem=42&lt;/a&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4319413"&gt;https://gist.github.com/4319413&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/38299197161</link><guid>http://is-r.tumblr.com/post/38299197161</guid><pubDate>Wed, 19 Dec 2012 07:28:42 -0500</pubDate><category>Rstats</category><category>AdventCalendaR</category></item><item><title>Making prettier network graphs with sna and igraph</title><description>&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_mexifzK1yZ1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;We&amp;#8217;ve had some requests for ideas about how to make prettier network graphs, so here is one example, using the &lt;a href="http://cran.r-project.org/web/packages/sna/index.html"&gt;sna&lt;/a&gt; package for plotting, and the &lt;a href="http://cran.r-project.org/web/packages/igraph/index.html"&gt;igraph&lt;/a&gt; package to calculate &lt;a href="http://en.wikipedia.org/wiki/PageRank"&gt;PageRank&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The help file for &lt;a href="http://svitsrv25.epfl.ch/R-doc/library/sna/html/gplot.html"&gt;gplot&lt;/a&gt; is pretty self-explanatory, but Melissa Clarkson has &lt;a href="http://students.washington.edu/mclarkso/documents/gplot%20Ver2.pdf"&gt;produced the most thorough and impressive guide for any R function I&amp;#8217;ve ever seen&lt;/a&gt;, to better illustrate some of the options. Seriously, you should leave is.R() now, and go look at that guide.&lt;/p&gt;
&lt;p&gt;The network being plotted is a very small subset of the &lt;a href="https://twitter.com/isDotR"&gt;isDotR Twitter&lt;/a&gt; account ego network, hence isDotR&amp;#8217;s high centrality. The key point is that there are a lot of ways to move beyond the &lt;a href="http://www.stanford.edu/~messing/images/frnetunop.png"&gt;igraph default aesthetic&lt;/a&gt;, and make a two-dimensional graph layout with many dimensions encoded into it.&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_mexif6wno11qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4269893"&gt;https://gist.github.com/4269893&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/38240018815</link><guid>http://is-r.tumblr.com/post/38240018815</guid><pubDate>Tue, 18 Dec 2012 14:06:47 -0500</pubDate><category>rstats</category><category>sna</category><category>igraph</category><category>AdventCalendaR</category></item><item><title>The Inverse Herfindahl–Hirschman Index as an "Effective Number of" Parties</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_mevr2yJR4Q1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;I learned of the passing of &lt;a href="http://en.wikipedia.org/wiki/Albert_O._Hirschman"&gt;Albert Hirschman&lt;/a&gt; on Decem&lt;span&gt;ber 11, and while better and more instructive tributes to his life can be read &lt;/span&gt;&lt;a href="http://marginalrevolution.com/marginalrevolution/2012/12/albert-o-hirschman.html"&gt;elsewhere&lt;/a&gt;&lt;span&gt;, I wanted to focus on a little piece of Hirschman&amp;#8217;s work that I use all the time: the (inverse) &lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Herfindahl_index"&gt;Herfindahl–Hirschman Index&lt;/a&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://www.jstor.org/discover/10.2307/1818582?uid=3739776&amp;amp;uid=2&amp;amp;uid=4&amp;amp;uid=3739256&amp;amp;sid=21101551661407"&gt;HHI&lt;/a&gt; is basically a measure of market concentration, but when inverted, it is an &amp;#8220;effective number of&amp;#8221; whatever grouping you might be interested in, such as &lt;a href="http://en.wikipedia.org/wiki/Effective_number_of_parties"&gt;parties&lt;/a&gt;. Essentially, this statistic can be interpreted as, &amp;#8220;Individuals are distributed across groups in such a way that they are as concentrated as they would be if divided across [HHI value] groups evenly.&amp;#8221;&lt;/p&gt;
&lt;p&gt;This is perhaps best understood by example, and fortunately, my field of American Politics offers an interesting one. The U.S. South, between Reconstruction and the Civil Rights Act, was commonly known as the &amp;#8220;one-party South,&amp;#8221; due to the &lt;a href="http://en.wikipedia.org/wiki/Solid_South"&gt;overwhelming dominance&lt;/a&gt; of the Democratic Party in Southern Politics. We can see evidence of this dominance by calculating the Effective Number of Parties-in-the-Electorate, using the HHI.&lt;/p&gt;
&lt;p&gt;As the graph below illustrates, non-Southern states have consistently featured just over two &amp;#8220;effective&amp;#8221; parties (Democrats, Republicans, and some Independents/Others), while the South lagged behind in this measure up until the 1980s.&lt;/p&gt;
&lt;p&gt;The inverse HHI is an elegant little function (the square of the sum over the sum of the squares), and &lt;a href="http://cran.r-project.org/web/packages/plyr/index.html"&gt;plyr&lt;/a&gt; makes it very easy to calculate for any dataset.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_mevr72FGEc1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4261011"&gt;https://gist.github.com/4261011&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/38140710276</link><guid>http://is-r.tumblr.com/post/38140710276</guid><pubDate>Mon, 17 Dec 2012 06:35:25 -0500</pubDate><category>rstats</category><category>plyr</category><category>ggplot2</category><category>AdventCalendaR</category></item><item><title>Possibly slightly better text analysis with lme4</title><description>&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_mevoylenCJ1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://cran.r-project.org/web/packages/lme4/index.html"&gt;lme4&lt;/a&gt; and its cousin &lt;a href="http://cran.r-project.org/web/packages/arm/"&gt;arm&lt;/a&gt; are extremely useful for a huge variety of modeling applications (&lt;a href="http://www.stat.columbia.edu/~gelman/arm/"&gt;see Gelman and Hill&amp;#8217;s book&lt;/a&gt;), but today we&amp;#8217;re going to do something a little frivolous with them. Namely, we&amp;#8217;re going to extend our Denver Debate analysis to include some sense of error.&lt;/p&gt;
&lt;p&gt;Instead of the term-frequency scatter plot seen in the previous post, this code fits the most basic possible partially-pooled model predicting which of the two candidates, Obama or Romney, spoke a given term. This allows us to get a slightly better idea of which candidate &amp;#8220;owned&amp;#8221; a term on the night, and simultaneously accounts for volume of usage (evidenced by narrower confidence intervals).&lt;/p&gt;
&lt;p&gt;Anyway, we will almost certainly return to &lt;a href="http://www.inside-r.org/packages/cran/lme4/docs/lmer"&gt;lmer()&lt;/a&gt; at some point in the future, but this code offers some ideas as to how best translate a model object into a data frame amenable to plotting.&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_mevp1dcN0c1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4260706"&gt;https://gist.github.com/4260706&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/38055963968</link><guid>http://is-r.tumblr.com/post/38055963968</guid><pubDate>Sun, 16 Dec 2012 06:33:49 -0500</pubDate><category>rstats</category><category>zoo</category><category>tm</category><category>ggplot2</category><category>lme4</category><category>arm</category><category>Snowball</category><category>AdventCalendaR</category></item><item><title>Text analysis made too easy with the tm package</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_mevlm4RNpE1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;Today&amp;#8217;s Gist takes the CNN transcript of the &lt;a href="http://debate2012.du.edu/"&gt;Denver Presidential Debate&lt;/a&gt;, converts paragraphs into a &lt;a href="http://en.wikipedia.org/wiki/Document-term_matrix"&gt;document-term matrix&lt;/a&gt;, and does the absolute most basic form of text analysis: a raw word count.&lt;/p&gt;
&lt;p&gt;There are actually quite a few steps in this process, though it is made easier with reference to the &lt;a href="http://cran.r-project.org/web/packages/tm/index.html"&gt;tm&lt;/a&gt; &lt;a href="http://cran.r-project.org/web/packages/tm/vignettes/tm.pdf"&gt;vignette&lt;/a&gt;, but you would do well to update R, re-install the relevant packages, and make sure you have a recent version of Java installed on your computer: this code has lots of dependencies.&lt;/p&gt;
&lt;p&gt;Please keep in mind that this Gist is intended only to illustrate the basic functionality of the tm package. Text analysis is difficult to do well, and a term frequency scatter plot does not qualify as &amp;#8220;done well.&amp;#8221; At least it&amp;#8217;s &lt;a href="http://www.niemanlab.org/2011/10/word-clouds-considered-harmful/"&gt;not a Wordle&lt;/a&gt; (&lt;a href="http://www.zeldman.com/daily/0405d.shtml"&gt;the mullet of the internet?&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_mevlkh7lIN1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4260167"&gt;https://gist.github.com/4260167&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/37975717466</link><guid>http://is-r.tumblr.com/post/37975717466</guid><pubDate>Sat, 15 Dec 2012 06:44:21 -0500</pubDate><category>rstats</category><category>zoo</category><category>tm</category><category>ggplot2</category><category>Snowball</category><category>AdventCalendaR</category></item><item><title>Everything is a Network, featuring the sna package</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_mevcbv7lnT1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;We&amp;#8217;ve gotten some requests, through the &lt;a href="http://is-r.tumblr.com/ask"&gt;Ask us anything&lt;/a&gt; page, to do some plotting of networks. We may come back to this later, but today&amp;#8217;s Gist shows how you can plot pretty much literally anything as a network.&lt;/p&gt;
&lt;p&gt;First, we go back to our &lt;a href="http://is-r.tumblr.com/post/34092273022/distribution-of-colors-by-flag"&gt;well-worn folder of flag PNGs&lt;/a&gt; from &lt;a href="https://www.gosquared.com/resources/2400-flags"&gt;GoSquared&lt;/a&gt;, and load data for each pixel of each flag. Then, we binarize the dissimilarity matrix of these flags, with a cutoff chosen to ensure that the entire graph is a single connected component (this is done just for the purposes of this example; in Real Life, you are likely to have an actual network you want to plot).&lt;/p&gt;
&lt;p&gt;Then, we plot the network conventionally, using &lt;a href="http://svitsrv25.epfl.ch/R-doc/library/sna/html/gplot.html"&gt;gplot&lt;/a&gt; from &lt;a href="http://cran.r-project.org/web/packages/sna/index.html"&gt;sna&lt;/a&gt;, but save the vertex coordinates. Finally, we replot the graph edges put overplot the vertices with the flag rasters that we have come to know and love.&lt;/p&gt;
&lt;p&gt;Fun &amp;#8220;fact&amp;#8221;: the &lt;a href="http://en.wikipedia.org/wiki/File:Flag_of_Seychelles.svg"&gt;flag of the Seychelles&lt;/a&gt; has the highest &lt;a href="http://en.wikipedia.org/wiki/Centrality#Eigenvector_centrality"&gt;eigenvector centrality&lt;/a&gt;, while the &lt;a href="http://en.wikipedia.org/wiki/File:Flag_of_the_Vatican_City.svg"&gt;flag of the Vatican City&lt;/a&gt; has the lowest!&lt;/p&gt;
&lt;p&gt;&lt;a href="https://raw.github.com/dsparks/Test_image/master/netTest.png"&gt;&lt;img src="http://media.tumblr.com/tumblr_mevcf1byA81qz4s35.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4258605"&gt;https://gist.github.com/4258605&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/37901909845</link><guid>http://is-r.tumblr.com/post/37901909845</guid><pubDate>Fri, 14 Dec 2012 06:30:24 -0500</pubDate><category>rstats</category><category>png</category><category>sna</category><category>AdventCalendaR</category></item><item><title>Fuzzy clustering with fanny()</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_meunb4fxuZ1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;This is kind of a fun example, and you might find the &lt;a href="http://en.wikipedia.org/wiki/Fuzzy_clustering"&gt;fuzzy clustering&lt;/a&gt; technique useful, as I have, for exploratory data analysis. In this Gist, I use the unparalleled &lt;a href="https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/smacof/man/breakfast.Rd?root=psychor&amp;amp;content-type=text%2Fplain"&gt;breakfast&lt;/a&gt; dataset from the smacof package, derive dissimilarities from breakfast item preference correlations, and use those dissimilarities to cluster foods.&lt;/p&gt;
&lt;p&gt;Fuzzy clustering with &lt;a href="http://stat.ethz.ch/R-manual/R-devel/library/cluster/html/fanny.html"&gt;fanny()&lt;/a&gt; is different from k-means and hierarchical clustering, in that it returns probabilities of membership for each observation in each cluster. Here, I ask for three clusters, so I can represent probabilities in RGB color space, and plot text in boxes with the help of &lt;a href="http://stackoverflow.com/a/7661309/479554"&gt;this StackOverflow answer&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The colors and the MDS configuration highlight the three primary clusterings of breakfast items into what we&amp;#8217;ll call a muffin group, a bread group, and a sweet group. Of course, cluster identification is a subjective exercise, made even more so by use of probabilistic membership, but I&amp;#8217;m pretty happy with this breakfast analysis.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_meunc5jgw71qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4255895"&gt;https://gist.github.com/4255895&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/37826141731</link><guid>http://is-r.tumblr.com/post/37826141731</guid><pubDate>Thu, 13 Dec 2012 06:30:32 -0500</pubDate><category>rstats</category><category>ggplot2</category><category>cluster</category><category>MASS</category><category>smacof</category><category>AdventCalendaR</category></item><item><title>Multidimensional metric unfolding with SMACOF</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_metwdi6owg1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;SMACOF stands for &amp;#8220;&lt;a href="http://cran.r-project.org/web/packages/smacof/vignettes/smacof.pdf"&gt;Scaling by MAjorizing a COmplicated Function&lt;/a&gt;,&amp;#8221; and it is a &lt;a href="http://en.wikipedia.org/wiki/Multidimensional_scaling"&gt;multidimensional scaling&lt;/a&gt; algorithm for metric unfolding of, among other things, rectangular ratings matrices.&lt;/p&gt;
&lt;p&gt;One neat Political Science application of MDS is inferring ideology from survey thermometer ratings. The &lt;a href="http://www.electionstudies.org/studypages/2008prepost/2008prepost.htm"&gt;2008 ANES&lt;/a&gt; featured 43 different thermometer stimuli, and today&amp;#8217;s Gist shows how to use SMACOF to simultaneously scale survey respondents and thermometer stimuli in the same space, and to compare this measure of inferred ideology across partisans.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve also got a little piece of code that replaces numeric axis labels with names of the stimuli, which I think might be better, as the numbers don&amp;#8217;t really mean much except in comparison with the stimuli. Let me know what you think!&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_metwcwSMAk1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4252470"&gt;https://gist.github.com/4252470&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/37782370200</link><guid>http://is-r.tumblr.com/post/37782370200</guid><pubDate>Wed, 12 Dec 2012 06:30:32 -0500</pubDate><category>ggplot2</category><category>smacof</category><category>rstats</category><category>AdventCalendaR</category></item><item><title>US State Maps using map_data()</title><description>&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_mettprTuBX1rwydv6.png"/&gt;&lt;/p&gt;
&lt;p&gt;Today&amp;#8217;s short post will show how to make a simple map using map_data().&lt;/p&gt;
&lt;p&gt;Let&amp;#8217;s assume you have data in a CSV file that may look like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_metttwhIYH1rwydv6.png"/&gt;&lt;/p&gt;
&lt;p&gt;Notice the lower case state names; they will make merging the data much easier. The variable of interest we&amp;#8217;re going to plot is the relative incarceration rates by race (whites and blacks) across each of the fifty states (we&amp;#8217;ll remove DC once we load the data). Using the map_data(&amp;#8220;state&amp;#8221;) command, we can load a data.frame called &amp;#8220;all_states&amp;#8221;, shown below:&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_mettyumDcu1rwydv6.png"/&gt;&lt;/p&gt;
&lt;p&gt;Merging that data with the data frame we have as a CSV produces:&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_mettzmRTjc1rwydv6.png"/&gt;&lt;/p&gt;
&lt;p&gt;We can then plot each state and shade it by our variable of interest:&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" src="http://media.tumblr.com/tumblr_metu047l4E1rwydv6.png"/&gt;&lt;/p&gt;
&lt;p&gt;Full code is below:&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4252133"&gt;https://gist.github.com/4252133&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/37708137014</link><guid>http://is-r.tumblr.com/post/37708137014</guid><pubDate>Tue, 11 Dec 2012 06:30:33 -0500</pubDate><category>graphics</category><category>rstats</category><category>ggplot2</category><category>AdventCalendaR</category></item><item><title>Can you please post the R code for making that beautiful Advent CalendarR? Pretty please. I've been trying to get it right but no luck :(</title><description>&lt;p&gt;I’m glad you like it! The code is a simple loop, drawing 24 open circles, some filled circles, and plotting numbers inside of those. Stripping out all of the axes and labels leaves us with a white field full of dots.&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4255340"&gt;https://gist.github.com/4255340&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/37687431723</link><guid>http://is-r.tumblr.com/post/37687431723</guid><pubDate>Mon, 10 Dec 2012 22:03:58 -0500</pubDate><category>AdventCalendaR</category></item><item><title>"Economics-style" graphs with bezier() from Hmisc</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_memvgwJbmK1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;So, I really think this one is pretty cool. We spend much of our time in R making graphs with data, but what if you have a theory that you&amp;#8217;d like to express graphically? Something like what I&amp;#8217;ll call &amp;#8220;&lt;a href="https://www.google.com/search?hl=en&amp;amp;q=econ-style+graphs&amp;amp;bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&amp;amp;bpcl=39650382&amp;amp;biw=944&amp;amp;bih=927&amp;amp;um=1&amp;amp;ie=UTF-8&amp;amp;tbm=isch&amp;amp;source=og&amp;amp;sa=N&amp;amp;tab=wi&amp;amp;ei=LijBUOSsJ8Xv0gG8oIAY#um=1&amp;amp;hl=en&amp;amp;tbo=d&amp;amp;tbm=isch&amp;amp;sa=1&amp;amp;q=economics+graphs&amp;amp;oq=economics+graphs&amp;amp;gs_l=img.3..0j0i24l9.2543.2543.5.3194.1.1.0.0.0.0.92.92.1.1.0...0.0...1c.t7c3phE9FmI&amp;amp;pbx=1&amp;amp;bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&amp;amp;fp=b04e39065c48ac0&amp;amp;bpcl=39650382&amp;amp;biw=944&amp;amp;bih=927"&gt;economics-style&amp;#8221; graphs&lt;/a&gt;, illustrating, for example, the &lt;a href="http://en.wikipedia.org/wiki/File:Solow_growth_model1.png"&gt;Solow growth model&lt;/a&gt;, a &lt;a href="http://en.wikipedia.org/wiki/File:Production_Possibilities_Frontier_Curve.svg"&gt;production–possibility frontier&lt;/a&gt;, or an &lt;a href="http://en.wikipedia.org/wiki/File:Simple-indifference-curves.svg"&gt;indifference curve&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Well, rest assured that R can produce those, too, and it&amp;#8217;s made simple by the &lt;a href="http://svitsrv25.epfl.ch/R-doc/library/Hmisc/html/labcurve.html"&gt;bezier() &lt;/a&gt;function from &lt;a href="http://cran.r-project.org/web/packages/Hmisc/index.html"&gt;Hmisc&lt;/a&gt; (Hmisc does a lot of other interesting things, but this is what you got in today&amp;#8217;s Advent CalendaR slot). &lt;a href="http://en.wikipedia.org/wiki/Bezier_curve"&gt;Bézier curves&lt;/a&gt; are a workhorse of vector graphics, and if you&amp;#8217;re not familiar with them, I encourage you to become so, with this &lt;a href="http://www.jasondavies.com/animated-bezier/"&gt;beautiful interactive demo&lt;/a&gt; and with this &lt;a href="http://processingjs.nihongoresources.com/bezierinfo/"&gt;more detailed interactive demo&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The Gist shows you how to use Bézier curves to replicate &lt;a href="http://en.wikipedia.org/w/index.php?title=File:Supply-demand-right-shift-demand.svg&amp;amp;page=1"&gt;Wikipedia&amp;#8217;s Supply-and-Demand graph&lt;/a&gt;, and is pretty heavily commented, but I&amp;#8217;ll add a few notes:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Generating a Bézier curve with pre-specified x and y vectors takes some trial-and-error. Fortunately, it is usually a fun puzzle and it&amp;#8217;s very quick to test. Just think of each point as &amp;#8220;pulling&amp;#8221; the curve toward itself.&lt;/li&gt;
&lt;li&gt;The script defines a hacky little function called approxIntersection(), which is intended to let you input two (x, y) vectors and will output their approximate intersection. This probably doesn&amp;#8217;t work well in a lot of cases, and I would be interested in hearing of anyone&amp;#8217;s less hacky solutions.&lt;/li&gt;
&lt;li&gt;Earlier drafts of this code required a bit of ggplot2 theme-wrangling, but with the release of &lt;a href="http://cran.r-project.org/web/packages/ggplot2/NEWS"&gt;ggplot2&amp;#160;0.9.3&lt;/a&gt;, theme_classic now produces the exact look I was going for.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_memvfnCIVP1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4229410"&gt;https://gist.github.com/4229410&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/37631901708</link><guid>http://is-r.tumblr.com/post/37631901708</guid><pubDate>Mon, 10 Dec 2012 06:30:27 -0500</pubDate><category>Hmisc</category><category>ggplot2</category><category>proxy</category><category>grid</category><category>rstats</category><category>AdventCalendaR</category></item><item><title>Handling missing data with Amelia</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_mem63xtYQh1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;So, what if you have data, but some of the observations are missing? Many statistical techniques assume no missingness, so we might want to &amp;#8220;fill in&amp;#8221; or rectangularize our data, by &lt;a href="http://en.wikipedia.org/wiki/Imputation_(statistics)"&gt;replacing missing observations with plausible substitutes&lt;/a&gt;. There are many ways of going about this, but one of the most robust and accessible is through the &lt;a href="http://cran.r-project.org/web/packages/Amelia/index.html"&gt;Amelia package&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Today&amp;#8217;s Gist applies multiple imputation to some sample ANES survey data, and compares listwise-deleted regression results to results pooled from the same regression run on ten imputed data sets. Amelia makes this imputation, modeling, and recombination straightforward, and I&amp;#8217;ve thrown in a nice coefficient plot (using &lt;a href="http://docs.ggplot2.org/current/position_dodge.html"&gt;position_dodge&lt;/a&gt;!) to illustrate the differences between missing data approaches.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_mem64hPxLz1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4224887"&gt;https://gist.github.com/4224887&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/37547995110</link><guid>http://is-r.tumblr.com/post/37547995110</guid><pubDate>Sun, 09 Dec 2012 06:30:38 -0500</pubDate><category>rstats</category><category>Amelia</category><category>ggplot2</category><category>AdventCalendaR</category></item><item><title>Evaluating term popularity with twitteR</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_mekw59ucWS1qz4s35.png"/&gt;&lt;/p&gt;
&lt;p&gt;I really wanted to put something together for this series on the &lt;a href="http://cran.r-project.org/web/packages/twitteR/index.html"&gt;twitteR package&lt;/a&gt;. Unfortunately, at the moment the number of interesting things than can be done with twitteR, as opposed to through API calls and &lt;a href="http://cran.r-project.org/web/packages/RCurl/index.html"&gt;RCurl&lt;/a&gt;, is limited. Regardless, I have Yet Another Invented Application to illustrate a pretty typical use-case for twitteR: grabbing Tweets by search term.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve done this before, for sentiment analysis of Tweets about Republican presidential primary candidates, and indeed, despite its limitations, the &lt;a href="http://www.inside-r.org/packages/cran/twitteR/docs/Rtweets"&gt;searchTwitter()&lt;/a&gt; function can be useful. Since the number of Tweets one can grab appears to be limited to 1000, this Gist attempts to infer term popularity by frequency &amp;#8212; with only minor success, as you can see in the plot below.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_mekw4sBCml1qz4s35.png"/&gt;&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4219950"&gt;https://gist.github.com/4219950&lt;/a&gt;&lt;/div&gt;</description><link>http://is-r.tumblr.com/post/37468761327</link><guid>http://is-r.tumblr.com/post/37468761327</guid><pubDate>Sat, 08 Dec 2012 06:30:28 -0500</pubDate><category>rstats</category><category>twitteR</category><category>lubridate</category><category>AdventCalendaR</category></item></channel></rss>
