<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Things I tend to forget</title>
	<atom:link href="http://jeffreybreen.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeffreybreen.wordpress.com</link>
	<description>if I don&#039;t write it down, I have to google for it again</description>
	<lastBuildDate>Fri, 23 Dec 2011 15:19:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jeffreybreen.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Things I tend to forget</title>
		<link>http://jeffreybreen.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jeffreybreen.wordpress.com/osd.xml" title="Things I tend to forget" />
	<atom:link rel='hub' href='http://jeffreybreen.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Use geom_rect() to add recession bars to your time series plots #rstats #ggplot</title>
		<link>http://jeffreybreen.wordpress.com/2011/08/15/recession-bars/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/08/15/recession-bars/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 03:50:56 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Federal Reserve]]></category>
		<category><![CDATA[FRED]]></category>
		<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[quantmod]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=411</guid>
		<description><![CDATA[ggplot2's geom_rect() layer makes it easy to highlight portions of your graph, such as recessions on an economic time series.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=411&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://moderntoolmaking.blogspot.com/2011/08/forecasting-recessions.html">Zach Mayer&#8217;s work reproducing John Hussman&#8217;s Recession Warning Composite</a> prompted me to dig this trick out of my (Evernote) notebook.</p>
<p>First, let&#8217;s grab some data to plot using the very handy <code>getSymbols()</code> function from <a href="http://www.quantmod.com/">Jeffrey Ryan&#8217;s quantmod package</a>. We&#8217;ll load the U.S. unemployment rate (<code>UNRATE</code>) from the St. Loius Fed&#8217;s Federal Reserve Economic Data (<code>src="FRED"</code>) and load the time series into a <code>data.frame</code>:</p>
<p><pre class="brush: r; light: true;">
unrate = getSymbols('UNRATE',src='FRED', auto.assign=F) 
unrate.df = data.frame(date=time(unrate), coredata(unrate) )
</pre></p>
<p>Now FRED provides a <code>USREC</code> time series which we could use to draw the recessions. It&#8217;s a bit awkward, though, as it contains a boolean to flag recession months since January 1921. All we really want are the start and end dates of each recession. Fortunately, the St. Louis Fed publishes just such a table on their web site. (See the answer to &#8220;What dates are used for the US recession bars in FRED graphs?&#8221; on <a href="http://research.stlouisfed.org/fred2/help-faq/">http://research.stlouisfed.org/fred2/help-faq/</a>.) Sometimes it&#8217;s still easier to cut-and-paste (and the static table covers another 64 years, go figure):</p>
<p><pre class="brush: r; light: true;">
recessions.df = read.table(textConnection(
&quot;Peak, Trough
1857-06-01, 1858-12-01
1860-10-01, 1861-06-01
1865-04-01, 1867-12-01
1869-06-01, 1870-12-01
1873-10-01, 1879-03-01
1882-03-01, 1885-05-01
1887-03-01, 1888-04-01
1890-07-01, 1891-05-01
1893-01-01, 1894-06-01
1895-12-01, 1897-06-01
1899-06-01, 1900-12-01
1902-09-01, 1904-08-01
1907-05-01, 1908-06-01
1910-01-01, 1912-01-01
1913-01-01, 1914-12-01
1918-08-01, 1919-03-01
1920-01-01, 1921-07-01
1923-05-01, 1924-07-01
1926-10-01, 1927-11-01
1929-08-01, 1933-03-01
1937-05-01, 1938-06-01
1945-02-01, 1945-10-01
1948-11-01, 1949-10-01
1953-07-01, 1954-05-01
1957-08-01, 1958-04-01
1960-04-01, 1961-02-01
1969-12-01, 1970-11-01
1973-11-01, 1975-03-01
1980-01-01, 1980-07-01
1981-07-01, 1982-11-01
1990-07-01, 1991-03-01
2001-03-01, 2001-11-01
2007-12-01, 2009-06-01&quot;), sep=',',
colClasses=c('Date', 'Date'), header=TRUE)
</pre></p>
<p>Now the only &#8220;gotcha&#8221; is that our recession data start long before our unemployment data, so let&#8217;s trim it to match:</p>
<p>
recessions.trim = subset(recessions.df, Peak &gt;= min(unrate.df$date) )
</p>
<p>Finally, we use ggplot2&#8242;s <code>geom_line()</code> layer to draw the unemployment data and transparent (<code>alpha=0.2</code>) pink rectangles to overlay the recessions:</p>
<p><pre class="brush: r; light: true;">
g = ggplot(unrate.df) + geom_line(aes(x=date, y=UNRATE)) + theme_bw()
g = g + geom_rect(data=recessions.trim, aes(xmin=Peak, xmax=Trough, ymin=-Inf, ymax=+Inf), fill='pink', alpha=0.2)
</pre></p>
<p><a href="http://jeffreybreen.files.wordpress.com/2011/08/rplot.png"><img src="http://jeffreybreen.files.wordpress.com/2011/08/rplot.png?w=600&#038;h=270" alt="" title="recession bars" width="600" height="270" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/411/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=411&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/08/15/recession-bars/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>

		<media:content url="http://jeffreybreen.files.wordpress.com/2011/08/rplot.png?w=600" medium="image">
			<media:title type="html">recession bars</media:title>
		</media:content>
	</item>
		<item>
		<title>One-liners which make me love R: twitteR&#8217;s searchTwitter() #rstats</title>
		<link>http://jeffreybreen.wordpress.com/2011/07/21/one-liners-twitter/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/07/21/one-liners-twitter/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 15:00:26 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[One-liners]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=320</guid>
		<description><![CDATA[R reminds me a lot of English. It&#8217;s easy to get started, but very difficult to master. So for all those times I&#8217;ve spent&#8230; well, forever&#8230; trying to figure out the &#8220;R way&#8221; of doing something, I&#8217;m glad to share these quick wins. My recent R tutorial on mining Twitter for consumer sentiment wouldn&#8217;t have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=320&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>R reminds me a lot of English. It&#8217;s easy to get started, but very difficult to master. So for all those times I&#8217;ve spent&#8230; well, forever&#8230; trying to figure out the &#8220;R way&#8221; of doing something, I&#8217;m glad to share these quick wins.</p>
<p>My recent <a href="http://jeffreybreen.wordpress.com/2011/07/04/twitter-text-mining-r-slides/">R tutorial on mining Twitter for consumer sentiment</a> wouldn&#8217;t have been possible without Jeff Gentry&#8217;s amazing twitteR package (<a href="http://cran.r-project.org/web/packages/twitteR/">available on CRAN</a>). It does so much of the behind-the-scenes heavy lifting to access Twitter&#8217;s REST APIs, that one line of code is all you need to perform a search and retrieve the (even paginated) results:</p>
<p><pre class="brush: r; highlight: [3]; light: true;">
library(twitteR)

tweets = searchTwitter(&quot;#rstats&quot;, n=1500)
</pre></p>
<p>You can search for anything, of course, &#8220;#rstats&#8221; is just an example. (And if you&#8217;re really into that hashtag, the twitteR package even provides an <code>Rtweets()</code> function which hardcodes that search string for you.) The <code>n=1500</code> specifies the maximum number of tweets supported by the Search API, though you may retrieve fewer as Twitter&#8217;s search indices contain only a couple of days&#8217; tweets.</p>
<p>What you get back is a list of tweets (technically &#8220;status updates&#8221;):</p>
<p><pre class="brush: r; highlight: [1,20]; light: true;">
&gt; head(tweets)
[[1]]
[1] &quot;Cloudnumberscom: CloudNumbers.com &#092;&#048;23 #Rstats gets real in the cloud http://t.co/Vw4Gupr via @AddToAny&quot;

[[2]]
[1] &quot;0_h_r_1: CloudNumbers.com &#092;&#048;23 #Rstats gets real in the cloud via DecisionStats - I came across Cloudnumbers.com . ... http://tinyurl.com/5sjagjg&quot;

[[3]]
[1] &quot;cmprsk: RT I just joined the beta to run #Rstats in the cloud with cloudnumbers.com http://t.co/lvVp0YJ via @cloudnumberscom http://bit.ly/lbSruR&quot;

[[4]]
[1] &quot;0_h_r_1: I just joined the beta to run #Rstats in the cloud with cloudnumbers.com http://t.co/lvVp0YJ via @cloudnumberscom&quot;

[[5]]
[1] &quot;cmprsk: RT man, the #rstats think people I am too soft on #sas, the #sas people think I am too soft on #wps, the #wps pe... http://bit.ly/innEv8&quot;

[[6]]
[1] &quot;keepstherainoff: Thanks to @cmprsk @geoffjentry and @MikeKSmith for colour-coded #Rstats GUI advice&quot;

&gt; class(tweets[[1]])
[1] &quot;status&quot;
attr(,&quot;package&quot;)
[1] &quot;twitteR&quot;
</pre></p>
<p>Now that you have some tweets, <a href="http://jeffreybreen.wordpress.com/2011/07/04/twitter-text-mining-r-slides/">the fun really begins</a>. To get you started, the <code>status</code> class includes a very handy <code>toDataFrame()</code> accessor method (see <code>?status</code>):</p>
<p><pre class="brush: r; light: true;">
&gt; library(plyr) 
&gt; tweets.df = ldply(tweets, function(t) t$toDataFrame() )
</pre><br />
<img src="http://jeffreybreen.files.wordpress.com/2011/07/tweets-df.png?w=780" alt="" title="tweets.df"   class="alignnone size-full wp-image-396" /><br />
<pre class="brush: r; highlight: [1]; light: true;">
&gt; str(tweets.df)
'data.frame':	131 obs. of  10 variables:
 $ text        : Factor w/ 122 levels &quot;CloudNumbers.com &#092;&#048;23 #Rstats gets real in the cloud http://t.co/Vw4Gupr via @AddToAny&quot;,..: 1 2 3 4 5 6 7 8 9 10 ...
 $ favorited   : logi  NA NA NA NA NA NA ...
 $ replyToSN   : logi  NA NA NA NA NA NA ...
 $ created     : POSIXct, format: &quot;2011-07-04 13:50:39&quot; &quot;2011-07-04 13:48:10&quot; &quot;2011-07-04 13:29:00&quot; &quot;2011-07-04 13:23:42&quot; ...
 $ truncated   : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ replyToSID  : logi  NA NA NA NA NA NA ...
 $ id          : Factor w/ 131 levels &quot;87941406873751552&quot;,..: 1 2 3 4 5 6 7 8 9 10 ...
 $ replyToUID  : logi  NA NA NA NA NA NA ...
 $ statusSource: Factor w/ 17 levels &quot;&amp;lt;a href=&amp;quot;http://twitter.com/tweetbutton&amp;quot; rel=&amp;quot;nofollow&amp;quot;&amp;gt;Tweet Button&amp;lt;/a&amp;gt;&quot;,..: 1 2 3 1 3 4 5 5 3 4 ...
 $ screenName  : Factor w/ 64 levels &quot;Cloudnumberscom&quot;,..: 1 2 3 2 3 4 2 5 3 6 ...
</pre></p>
<p>You can pull a particular user&#8217;s tweets just as easily with the <code>userTimeline()</code> function. Heck, the package even lets you tweet from R if you use <a href="http://cran.r-project.org/web/packages/ROAuth/">Jeff&#8217;s companion ROAuth package</a>, but that requires more than one line&#8230;.</p>
<p>Enjoy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/320/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=320&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/07/21/one-liners-twitter/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>

		<media:content url="http://jeffreybreen.files.wordpress.com/2011/07/tweets-df.png" medium="image">
			<media:title type="html">tweets.df</media:title>
		</media:content>
	</item>
		<item>
		<title>Use Dropbox&#8217;s public folder for web publishing via Notepad (or emacs or&#8230;)</title>
		<link>http://jeffreybreen.wordpress.com/2011/07/19/web-publishing-via-dropbox/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/07/19/web-publishing-via-dropbox/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 16:12:39 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Dropbox]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=342</guid>
		<description><![CDATA[Remember The Good Old Days when all you needed to host a web site was a file system and Notepad (or emacs or TeachText)? Well, I do, and I can&#8217;t say that I miss them&#8230; until last week when I tried to insert the JavaScript for some motion charts into a WordPress.com post. It&#8217;s impossible. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=342&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Remember The Good Old Days when all you needed to host a web site was a file system and Notepad (or emacs or TeachText)? </p>
<p>Well, I do, and I can&#8217;t say that I miss them&#8230; until last week when I tried to insert the <a href="http://jeffreybreen.wordpress.com/2011/07/14/r-one-liners-googlevis/">JavaScript for some motion charts</a> into a WordPress.com post. It&#8217;s impossible. Literally. Don&#8217;t waste your time. Seriously.</p>
<p>Self-hosted WordPress blogs can use some <a href="http://wordpress.org/extend/plugins/custom-fields-shortcode/">custom field hackery</a>, but there&#8217;s no such option for us easy-way-out WordPress.com users.</p>
<h2>Dropbox to the rescue</h2>
<p>Just save your HTML page to your &#8220;Public&#8221; directory in Dropbox and it will get its own public URL which you can find in Dropbox&#8217;s context menu:</p>
<p><img src="http://jeffreybreen.files.wordpress.com/2011/07/dropbox-copy-public-link.png?w=780&#038;h=209" alt="" title="Dropbox &gt; Copy Public Link" width="780" height="209" class="alignnone size-full wp-image-381" /></p>
<p>It&#8217;s not the ideal embedding I was hoping for &#8212; WordPress.com even strips out iframes &#8212; but it&#8217;s quick and easy and does the job.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/342/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=342&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/07/19/web-publishing-via-dropbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>

		<media:content url="http://jeffreybreen.files.wordpress.com/2011/07/dropbox-copy-public-link.png" medium="image">
			<media:title type="html">Dropbox &#62; Copy Public Link</media:title>
		</media:content>
	</item>
		<item>
		<title>One-liners which make me love R: Make your data dance (Hans Rosling style) with googleVis #rstats</title>
		<link>http://jeffreybreen.wordpress.com/2011/07/14/r-one-liners-googlevis/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/07/14/r-one-liners-googlevis/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 04:42:46 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[One-liners]]></category>
		<category><![CDATA[Google Visualization]]></category>
		<category><![CDATA[googleVis]]></category>
		<category><![CDATA[lazy]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=331</guid>
		<description><![CDATA[This inaugural post in my "one-liners which make me love R" series highlights the googleVis package which makes it easy to use the Google Visualization API from R. Thanks to googleVis, just one line of R generates the 165 lines of HTML and (mostly) JavaScript required to create a Hans Rosling-style motion chart for some sample data.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=331&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It may be a cliché, but much of R&#8217;s utility comes from its amazing community. And by community, I am specifically referring to the bright, hard-working people who are willing to share their knowledge and code with the rest of us. Because of their contributions, we can do some amazingly cool and useful things with very little code of our own. It is in this context that I launch this new series to highlight packages and functions which make it easy to do jaw-droppingly cool and useful things.</p>
<p>First up: the <a href="http://cran.r-project.org/web/packages/googleVis/">googleVis package</a> by Markus Gesmann and Diego de Castillo which makes it easy &#8212; often with just one-line of R &#8212; to harness the <a href="http://code.google.com/apis/chart/">Google Visualization API</a>. Annotated timelines, gauges, maps, org charts, tree maps, and more are suddenly at your command.</p>
<p>I&#8217;m going to focus on the motion chart, popularized by Hans Rosling in his <a href="http://www.ted.com/talks/hans_rosling_shows_the_best_stats_you_ve_ever_seen.html">groundbreaking 2006 TED talk on global economic development</a>. (If you haven&#8217;t seen it yet, you should. Right now. Seriously. <a href="http://www.ted.com/talks/hans_rosling_shows_the_best_stats_you_ve_ever_seen.html">Go.</a>) Motion charts are an innovative way to display multidimensional time series in an interactive way. And the googleVis package even comes with some sample data to make it even easier to try them out.</p>
<p>The package is available from CRAN if you need to install it.</p>
<p>To get started, load the package and the included &#8220;Fruits&#8221; <code>data.frame</code>:</p>
<p><pre class="brush: r; light: true;">
library(googleVis)
data(Fruits)
</pre></p>
<p>This <code>data.frame</code> contains some sample data about sales of various fruits at different locations for different years. There&#8217;s even a proper <code>Date</code> column already constructed for us from the <code>numeric</code> Year column:</p>
<p><img src="http://jeffreybreen.files.wordpress.com/2011/07/fruits.png?w=780" alt="" title="Fruits"   class="alignnone size-full wp-image-368" /></p>
<p>To make the chart, we need to give the <code>gvisMotionChart()</code> function our <code>data.frame</code> and tell it a few things about it: the column which identifies the items to examine (<code>idvar=Fruit</code>), the time dimension (<code>timevar=Date</code>), and optionally a name to use to identify the chart in the generated HTML and JavaScript (we&#8217;ll use <code>chartid="ILoveFruits"</code>):</p>
<p><pre class="brush: r; light: true;">
M = gvisMotionChart(data=Fruits, idvar=&quot;Fruit&quot;, timevar=&quot;Date&quot;, chartid=&quot;ILoveFruit&quot;)
</pre></p>
<p>That&#8217;s it.</p>
<p>You can view your chart with the overridden <code>plot()</code> function. It will automatically spawn a browser window and serve up your chart through R&#8217;s internal web server:</p>
<p><pre class="brush: r; light: true;">
plot(M)
</pre></p>
<p><em>Since WordPress doesn&#8217;t allow embedded JavaScript, <a href="http://dl.dropbox.com/u/4839225/www/motioncharts/ILoveFruits.html">please click through to see the motion chart in action</a>:</em><br />
<a href="http://dl.dropbox.com/u/4839225/www/motioncharts/ILoveFruits.html"><img src="http://jeffreybreen.files.wordpress.com/2011/07/ilovefruits.png?w=518&#038;h=483" alt="" title="ILoveFruits" width="518" height="483" class="alignnone" /></a></p>
<p>You can also access all 165 lines of the generated HTML and JavaScript and save it to disk:</p>
<p><pre class="brush: r; light: true;">
cat(unlist(M$html), file=&quot;output/ILoveFruits.html&quot;)
</pre></p>
<p>Time suck alert: googleVis may make them easy to create, but motion charts can be a lot of fun to play with. You have been warned&#8230;</p>
<p>If you want to take a look at an example with some real data, you might be interested in the <a href="http://www.cambridge.aero/_blog/main/post/US_Domestic_Airline_Market_In_Motion_1990-2010/">20 Years of the U.S. Domestic Airline Market In 20 seconds</a> post on my work blog.</p>
<p>Finally, here are the slides from my lightning talk on this topic at this month&#8217;s Greater Boston useR Group meeting:</p>
<iframe src='http://www.slideshare.net/slideshow/embed_code/8590025' width='780' height='639'></iframe>
<p>Have fun!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/331/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=331&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/07/14/r-one-liners-googlevis/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>

		<media:content url="http://jeffreybreen.files.wordpress.com/2011/07/fruits.png" medium="image">
			<media:title type="html">Fruits</media:title>
		</media:content>

		<media:content url="http://jeffreybreen.files.wordpress.com/2011/07/ilovefruits.png?w=300" medium="image">
			<media:title type="html">ILoveFruits</media:title>
		</media:content>
	</item>
		<item>
		<title>installing R 2.13.1 on Amazon EC2&#8242;s &#8220;Amazon Linux&#8221; AMI #rstats</title>
		<link>http://jeffreybreen.wordpress.com/2011/07/08/install-r-amazon-linux-ec2/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/07/08/install-r-amazon-linux-ec2/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 18:27:32 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=324</guid>
		<description><![CDATA[Condensed from this post (and comments) on David Chudzicki&#8217;s blog, tweaked, and updated for R-2.13.1. Assumes you&#8217;re starting with a virgin &#8220;Amazon Linux&#8221; AMI. I picked &#8220;Basic 64-bit Amazon Linux AMI 2011.02.1 Beta&#8221; (AMI Id: ami-8e1fece7) because it was marked as free tier eligible on the &#8220;Quick Start&#8221; tab of AWS&#8217;s &#8220;Launch Instance&#8221; dialog box: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=324&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Condensed from <a href="http://blog.davidchudzicki.com/2011/02/installing-r-on-amazon-linux.html">this post (and comments) on David Chudzicki&#8217;s blog</a>, tweaked, and updated for R-2.13.1. </p>
<p>Assumes you&#8217;re starting with a virgin &#8220;Amazon Linux&#8221; AMI. I picked &#8220;Basic 64-bit Amazon Linux AMI 2011.02.1 Beta&#8221; (AMI Id: ami-8e1fece7) because it was marked as free tier eligible on the &#8220;Quick Start&#8221; tab of AWS&#8217;s &#8220;Launch Instance&#8221; dialog box:</p>
<p><pre class="brush: plain; light: true;">
$ sudo yum -y install make libX11-devel.* libICE-devel.* libSM-devel.* libdmx-devel.* libx* xorg-x11* libFS* libX*  readline-devel gcc-gfortran gcc-c++ texinfo tetex

$ wget http://cran.r-project.org/src/base/R-2/R-2.13.1.tar.gz

$ tar zxf R-2.13.1.tar.gz &amp;&amp; cd R-2.13.1
$ ./configure &amp;&amp; make

$ # make coffee... or finish your PhD thesis... (yes, it takes that long)
[...]
$ # finally, if all is well:

$ sudo make install

$ cd
$ R --version
R version 2.13.1 (2011-07-08)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License version 2.
For more information about these matters see
http://www.gnu.org/licenses/.
</pre></p>
<p>As always, refer to the <a href="http://cran.r-project.org/doc/manuals/R-admin.pdf">Installation and Administration manual</a> for details and options.</p>
<p>If you want to install RCurl, or anything which depends on it like twitteR, you&#8217;ll need to install libcurl &amp; friends first:</p>
<p><pre class="brush: plain; light: true;">
$ sudo yum -y install libcurl libcurl-devel
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/324/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=324&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/07/08/install-r-amazon-linux-ec2/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>
	</item>
		<item>
		<title>slides from my R tutorial on Twitter text mining #rstats</title>
		<link>http://jeffreybreen.wordpress.com/2011/07/04/twitter-text-mining-r-slides/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/07/04/twitter-text-mining-r-slides/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 18:56:31 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[airlines]]></category>
		<category><![CDATA[Boston Predictive Analytics]]></category>
		<category><![CDATA[doBy]]></category>
		<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[Hu & Liu]]></category>
		<category><![CDATA[plyr]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[sentiment analysis]]></category>
		<category><![CDATA[text mining]]></category>
		<category><![CDATA[tm]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=311</guid>
		<description><![CDATA[Update: An expanded version of this tutorial will appear in the new Elsevier book Practical Text Mining and Statistical Analysis for Non-structured Text Data Applications by Gary Miner et. al which is now available for pre-order from Amazon. In conjunction with the book, I have cleaned up the tutorial code and published it on github. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=311&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><b>Update:</b> An expanded version of this tutorial will appear in the new Elsevier book <a href="http://ow.ly/63NWl">Practical Text Mining and Statistical Analysis for Non-structured Text Data Applications</a> by Gary Miner <i>et. al</i> which is now <a href="http://ow.ly/63NWl">available for pre-order from Amazon</a>.</p>
<p>In conjunction with the book, I have cleaned up the tutorial code and <a href="https://github.com/jeffreybreen/twitter-sentiment-analysis-tutorial-201107">published it on github.</a></p>
<hr />
<p>Last month I presented this introduction to R at the <a href="http://www.meetup.com/Boston-Predictive-Analytics/events/17462846/">Boston Predictive Analytics MeetUp</a> on Twitter Sentiment. </p>
<p>The goal of the presentation was to expose a first-time (but technically savvy) audience to working in R. The scenario we work through is to estimate the sentiment expressed in tweets about major U.S. airlines. Even with a tiny sample and a very crude algorithm (simply counting the number of positive vs. negative words), we find a believable result. We conclude by comparing our result with scores we scrape from the <a href="http://www.theacsi.org/">American Consumer Satisfaction Index web site</a>.</p>
<p>Jeff Gentry&#8217;s twitteR package makes it easy to fetch the tweets. Also featured are the plyr, ggplot2, doBy, and XML packages. A real analysis would, no doubt, lean heavily on the tm text mining package for stemming, etc.</p>
<p>Here is the slimmed-down version of the slides:</p>
<iframe src='http://www.slideshare.net/slideshow/embed_code/8504941' width='780' height='639'></iframe>
<p>And here&#8217;s a <a href="http://ow.ly/5Bn6K">PDF version</a> to download.</p>
<p>Special thanks to John Verostek for putting together such an interesting event, and for providing valuable feedback and help with these slides.</p>
<hr />
<p><strong>Update:</strong> thanks to eagle-eyed <a href="http://twitter.com/cdhowe">Carl Howe</a> for noticing a slightly out-of-date version of the <code>score.sentiment()</code> function in the deck. Missing was handling for <code>NA</code> values from <code>match()</code>. The deck has been updated and the code is reproduced here for convenience:</p>
<p><pre class="brush: r; light: true;">

score.sentiment = function(sentences, pos.words, neg.words, .progress='none')
{
	require(plyr)
	require(stringr)
	
	# we got a vector of sentences. plyr will handle a list
	# or a vector as an &quot;l&quot; for us
	# we want a simple array (&quot;a&quot;) of scores back, so we use 
	# &quot;l&quot; + &quot;a&quot; + &quot;ply&quot; = &quot;laply&quot;:
	scores = laply(sentences, function(sentence, pos.words, neg.words) {
		
		# clean up sentences with R's regex-driven global substitute, gsub():
		sentence = gsub('[[:punct:]]', '', sentence)
		sentence = gsub('[[:cntrl:]]', '', sentence)
		sentence = gsub('\\d+', '', sentence)
		# and convert to lower case:
		sentence = tolower(sentence)

		# split into words. str_split is in the stringr package
		word.list = str_split(sentence, '\\s+')
		# sometimes a list() is one level of hierarchy too much
		words = unlist(word.list)

		# compare our words to the dictionaries of positive &amp; negative terms
		pos.matches = match(words, pos.words)
		neg.matches = match(words, neg.words)
	
		# match() returns the position of the matched term or NA
		# we just want a TRUE/FALSE:
		pos.matches = !is.na(pos.matches)
		neg.matches = !is.na(neg.matches)

		# and conveniently enough, TRUE/FALSE will be treated as 1/0 by sum():
		score = sum(pos.matches) - sum(neg.matches)

		return(score)
	}, pos.words, neg.words, .progress=.progress )

	scores.df = data.frame(score=scores, text=sentences)
	return(scores.df)
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/311/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=311&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/07/04/twitter-text-mining-r-slides/feed/</wfw:commentRss>
		<slash:comments>69</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>
	</item>
		<item>
		<title>Hype isn&#8217;t limited to IT vendors: presenting my new Turbo Force High Velocity Circulator</title>
		<link>http://jeffreybreen.wordpress.com/2011/06/09/its-a-fan-for-godssake/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/06/09/its-a-fan-for-godssake/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 02:30:49 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[Honeywell]]></category>
		<category><![CDATA[hype]]></category>
		<category><![CDATA[marketing]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=298</guid>
		<description><![CDATA[Think IT vendors hype their products? Check out what Honeywell says about my new desk fan.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=298&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://jeffreybreen.files.wordpress.com/2011/06/ht-900-honeywell-turboforce-air-circulator-fan.jpg?w=780" alt="" title=""   class="alignright size-full wp-image-303" />
<p>I went to the store to purchase a small fan to blow nice cool air towards my desk. But when I got it home and took a closer look, it turns out that I had selected an <a href="http://www.honeywellstore.com/store/products/honeywell-turboforce-air-circulator-fan-ht-900.htm">HT-900 Turbo Force&reg; Air Circulator Fan from Honeywell</a>.
</p>
<p>Honeywell, eh? They make <a href="http://www.honeywellforjaguar.com/">jet engines</a> and <a href="http://www.sulfn26.com/explosives.php">ammonium nitrate fertilizer which won&#8217;t blow up</a>! Maybe there&#8217;s more to this fan than I realized.
</p>
<p>Intruiged, I started to read the <a href="http://assetsw.sellpoint.net/opt/apache/htdocs/__FileManager__/Org_100_5718/34672/35328/HT-900_OM-rev.pdf">Owner&#8217;s Manual</a>:</p>
<blockquote><p>The Turbo Force&reg; High Velocity Air Circulator Fans are aerodynamically designed to give you the versatility of changing this fan&#8217;s angular direction simply by adjusting the fan to ANY desired angular output (Fig.1).</p></blockquote>
<p>I think that means: It tilts.</p>
<p>The introduction continues:</p>
<blockquote><p>
Upon using this fan, you will feel a strong and powerful air stream that will quickly move air in order to cool an area rapidly and efficiently.
</p></blockquote>
<p>
Translation: Turn it on and it will blow air.
</p>
<p>
Suddenly all that vendor verbiage about how cloud computing will increase the synergies between your technology and business priorities sounds&#8230; well&#8230; not that bad. At least they&#8217;re not hyping something as simple as a desk fan.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/298/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=298&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/06/09/its-a-fan-for-godssake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>

		<media:content url="http://jeffreybreen.files.wordpress.com/2011/06/ht-900-honeywell-turboforce-air-circulator-fan.jpg" medium="image" />
	</item>
		<item>
		<title>googleVis-0.2.4 requires older version of RJSONIO (0.5-0) #rstats</title>
		<link>http://jeffreybreen.wordpress.com/2011/05/29/googlevis-needs-rjsonio-0-5/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/05/29/googlevis-needs-rjsonio-0-5/#comments</comments>
		<pubDate>Sun, 29 May 2011 19:56:09 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[googleVis]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[RJSONIO]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=290</guid>
		<description><![CDATA[Downgrade to RJSONIO 0.5 if you want to be able to set initial states with the current googleVis package. Otherwise, there will be lots of extra backslashes in your JavaScript--and blank pages in your browser.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=290&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>[<strong>Update:</strong> the new release of googleVis accounts for changes in RJSONIO's handling of backslashes, so you probably won't need the older version.]</p>
<p>Something has apparently changed in the way RJSON&#8217;s <code>toJSON()</code> function works which is causing all sorts of extra escape characters (backslashes) to appear in the googleVis-generated JavaScript, at least when trying to set a visualization&#8217;s initial state. This bogus code causes the browser&#8217;s JavaScript engine to choke just before it can call <code>chart.draw()</code>, so you don&#8217;t see the Flash visualization at all&#8211;just a blank space with the pretty footer.</p>
<p>This is at least the case on Mac OS 10.6.7 and <a href="http://code.google.com/p/google-motion-charts-with-r/issues/detail?id=5">Markus Gesmann gets all the credit for tracking it down</a>.</p>
<p>Here&#8217;s an example state string which selects a couple of bubbles to be labeled (&#8220;Oranges&#8221; and &#8220;Apples&#8221;) and sets the time to start about half-way through:</p>
<p><pre class="brush: r; light: true;">
state.json='{&quot;xAxisOption&quot;:&quot;3&quot;,&quot;xZoomedDataMin&quot;:81,&quot;playDuration&quot;:15000,&quot;sizeOption&quot;:&quot;_UNISIZE&quot;,&quot;xZoomedDataMax&quot;:111,&quot;xLambda&quot;:1,&quot;dimensions&quot;:{&quot;iconDimensions&quot;:[&quot;dim0&quot;]},&quot;yZoomedDataMax&quot;:91,&quot;duration&quot;:{&quot;multiplier&quot;:1,&quot;timeUnit&quot;:&quot;Y&quot;},&quot;orderedByX&quot;:false,&quot;xZoomedIn&quot;:false,&quot;yZoomedDataMin&quot;:71,&quot;showTrails&quot;:false,&quot;orderedByY&quot;:false,&quot;iconType&quot;:&quot;BUBBLE&quot;,&quot;uniColorForNonSelected&quot;:false,&quot;yZoomedIn&quot;:false,&quot;nonSelectedAlpha&quot;:0.4,&quot;yLambda&quot;:1,&quot;time&quot;:&quot;2010&quot;,&quot;yAxisOption&quot;:&quot;4&quot;,&quot;iconKeySettings&quot;:[{&quot;LabelY&quot;:27,&quot;key&quot;:{&quot;dim0&quot;:&quot;Apples&quot;},&quot;LabelX&quot;:42}],&quot;colorOption&quot;:&quot;6&quot;}'

# create the motion chart
M=gvisMotionChart(Fruits, &quot;Fruit&quot;, &quot;Year&quot;, options=list(state=state.json))
</pre></p>
<p>Here&#8217;s the output in question using the current RJSONIO 0.7:</p>
<p><pre class="brush: jscript; highlight: [1]; light: true;">
&gt; cat(M$html$chart['jsDrawChart'])

// jsDrawChart
function drawChartMotionChartID6db280db() {
  var data = gvisDataMotionChartID6db280db()
  var chart = new google.visualization.MotionChart(
   document.getElementById('MotionChartID6db280db')
  );
  var options ={};
options[&quot;width&quot;] = [    600 ];
options[&quot;height&quot;] = [    500 ];
options[&quot;state&quot;] = [ &quot;{\\&quot;xAxisOption\\&quot;:\\&quot;3\\&quot;,\\&quot;xZoomedDataMin\\&quot;:81,\\&quot;playDuration\\&quot;:15000,\\&quot;sizeOption\\&quot;:\\&quot;_UNISIZE\\&quot;,\\&quot;xZoomedDataMax\\&quot;:111,\\&quot;xLambda\\&quot;:1,\\&quot;dimensions\\&quot;:{\\&quot;iconDimensions\\&quot;:[\\&quot;dim0\\&quot;]},\\&quot;yZoomedDataMax\\&quot;:91,\\&quot;duration\\&quot;:{\\&quot;multiplier\\&quot;:1,\\&quot;timeUnit\\&quot;:\\&quot;Y\\&quot;},\\&quot;orderedByX\\&quot;:false,\\&quot;xZoomedIn\\&quot;:false,\\&quot;yZoomedDataMin\\&quot;:71,\\&quot;showTrails\\&quot;:false,\\&quot;orderedByY\\&quot;:false,\\&quot;iconType\\&quot;:\\&quot;BUBBLE\\&quot;,\\&quot;uniColorForNonSelected\\&quot;:false,\\&quot;yZoomedIn\\&quot;:false,\\&quot;nonSelectedAlpha\\&quot;:0.4,\\&quot;yLambda\\&quot;:1,\\&quot;time\\&quot;:\\&quot;2010\\&quot;,\\&quot;yAxisOption\\&quot;:\\&quot;4\\&quot;,\\&quot;iconKeySettings\\&quot;:[{\\&quot;LabelY\\&quot;:27,\\&quot;key\\&quot;:{\\&quot;dim0\\&quot;:\\&quot;Apples\\&quot;},\\&quot;LabelX\\&quot;:42}],\\&quot;colorOption\\&quot;:\\&quot;6\\&quot;}&quot; ];
  chart.draw(data,options);
}
</pre></p>
<p>And here&#8217;s working code from RJSONIO 0.5:</p>
<p><pre class="brush: jscript; highlight: [1]; light: true;">
&gt; cat(M$html$chart['jsDrawChart'])

// jsDrawChart
function drawChartMotionChartID47a55df7() {
  var data = gvisDataMotionChartID47a55df7()
  var chart = new google.visualization.MotionChart(
   document.getElementById('MotionChartID47a55df7')
  );
  var options ={};
options[&quot;width&quot;] =    600;
options[&quot;height&quot;] =    500;
options[&quot;state&quot;] = &quot;{\&quot;sizeOption\&quot;:\&quot;5\&quot;,\&quot;nonSelectedAlpha\&quot;:0.4,\&quot;xLambda\&quot;:1,\&quot;iconType\&quot;:\&quot;BUBBLE\&quot;,\&quot;yZoomedDataMax\&quot;:91,\&quot;iconKeySettings\&quot;:[{\&quot;LabelY\&quot;:-124,\&quot;LabelX\&quot;:-160,\&quot;key\&quot;:{\&quot;dim0\&quot;:\&quot;Oranges\&quot;}},{\&quot;LabelY\&quot;:53,\&quot;LabelX\&quot;:37,\&quot;key\&quot;:{\&quot;dim0\&quot;:\&quot;Apples\&quot;}}],\&quot;xZoomedIn\&quot;:false,\&quot;orderedByX\&quot;:false,\&quot;showTrails\&quot;:false,\&quot;yZoomedIn\&quot;:false,\&quot;yZoomedDataMin\&quot;:71,\&quot;xZoomedDataMin\&quot;:81,\&quot;orderedByY\&quot;:false,\&quot;xAxisOption\&quot;:\&quot;3\&quot;,\&quot;yAxisOption\&quot;:\&quot;4\&quot;,\&quot;uniColorForNonSelected\&quot;:false,\&quot;duration\&quot;:{\&quot;timeUnit\&quot;:\&quot;Y\&quot;,\&quot;multiplier\&quot;:1},\&quot;time\&quot;:\&quot;2009\&quot;,\&quot;yLambda\&quot;:1,\&quot;xZoomedDataMax\&quot;:111,\&quot;dimensions\&quot;:{\&quot;iconDimensions\&quot;:[\&quot;dim0\&quot;]},\&quot;colorOption\&quot;:\&quot;2\&quot;,\&quot;playDuration\&quot;:15000}&quot;;
  chart.draw(data,options);
}
</pre></p>
<p>Maybe this post can help others avoid the blank look I had on my face as I kept staring at a blank page in my browser.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/290/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=290&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/05/29/googlevis-needs-rjsonio-0-5/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>
	</item>
		<item>
		<title>quantmod makes it easy to watch silver prices crash in R #rstats</title>
		<link>http://jeffreybreen.wordpress.com/2011/05/07/quantmod-silver-prices/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/05/07/quantmod-silver-prices/#comments</comments>
		<pubDate>Sun, 08 May 2011 04:38:43 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[gold]]></category>
		<category><![CDATA[OANDA]]></category>
		<category><![CDATA[precious metals]]></category>
		<category><![CDATA[quantmod]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[silver]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=271</guid>
		<description><![CDATA[Jeffrey Ryan's quantmod package makes it simple to download and graph pricing data from a variety of sources. A couple of lines of R is all it takes to see that silver has had a very bad week.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=271&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As if there hasn&#8217;t been <a href="http://newsfeed.time.com/2011/05/02/rot-in-hell-the-best-bin-laden-headlines-in-u-s-papers/">enough</a> <a href="http://english.aljazeera.net/news/middleeast/2011/05/2011566163239760.html">going</a> <a href="http://www.guardian.co.uk/world/2011/may/05/ahmadinejad-allies-charged-with-sorcery">on</a> <a href="http://www.bloomberg.com/news/2011-05-06/u-s-payrolls-increased-244-000-in-april-unemployment-rate-climbs-to-9-.html">this</a> <a href="http://www.latimes.com/news/nationworld/nation/la-na-mississippi-floods-20110508,0,4435839.story">week</a>, silver prices have fallen nearly $10 per ounce. That&#8217;s a reduction of over 20%. <a href="http://www.quantmod.com/">Jeffrey Ryan&#8217;s quantmod package</a> makes it easy to download the latest prices from <a href="http://www.oanda.com/">OANDA&#8217;s web site</a> and plot the excitement.</p>
<p>The <code>getSymbols()</code> function is at the heart of quantmod&#8217;s data retrieval prowess, currently handling Yahoo! Finance, Google Finance, the St. Louis Fed&#8217;s FRED, and OANDA sites, in addition to MySQL databases and RData and CSV files.</p>
<p>First a word of warning: if you have a computer science background, you may cringe at the way <code>getSymbols()</code> returns data. Rather than returning the fetched data as the result of a function call, it populates your R session&#8217;s <code>.GlobalEnv</code> environment (or another one of your choosing via the <code>env</code> parameter) with <code>xts</code> and <code>zoo</code> objects containing your data. For example, if you ask for IBM&#8217;s stock prices via <code>getSymbols("IBM")</code>, you will find the data in a new &#8220;IBM&#8221; object in your <code>.GlobalEnv</code>. This behavior can be changed by setting <code>auto.assign=F</code>, but then you can only request one symbol at a time. But this is a minor nit about an incredibly useful package.</p>
<p>There&#8217;s even a wrapper function to help retrieve precious metal prices, and we will use this <code>getMetals()</code> function to retrieve the last year&#8217;s worth of prices for gold (XAU) and silver (XAG):</p>
<p><pre class="brush: r; light: true;">
library(quantmod)
getMetals(c('XAU', 'XAG'), from=Sys.Date()-365)
</pre></p>
<p>Yup &#8212; that&#8217;s it. <code>getMetals()</code> lets us know it has created two new objects:</p>
<p><pre class="brush: plain; light: true;">
[1] &quot;XAUUSD&quot; &quot;XAGUSD&quot;
</pre></p>
<p>There were also few warning messages complaining about the last line in the downloaded file. I haven&#8217;t bothered to dig into it as the data seem fine, including today&#8217;s price:</p>
<p><pre class="brush: r; highlight: [1,4,13]; light: true;">
&gt; ls()
[1] &quot;XAGUSD&quot; &quot;XAUUSD&quot;

&gt; head(XAGUSD)
           XAG.USD
2010-05-07 17.6600
2010-05-08 18.4600
2010-05-09 18.4320
2010-05-10 18.4336
2010-05-11 18.5400
2010-05-12 19.3300

&gt; tail(XAGUSD)
           XAG.USD
2011-05-02 47.9850
2011-05-03 45.2373
2011-05-04 44.0238
2011-05-05 40.9171
2011-05-06 37.9939
2011-05-07 35.0598
</pre></p>
<p>And here&#8217;s how easy it is to use the package&#8217;s built-in graphing facilities:</p>
<p><pre class="brush: r; light: true;">
chartSeries(XAUUSD, theme=&quot;white&quot;)
</pre><br />
<a href="http://jeffreybreen.files.wordpress.com/2011/05/xau.png"><img src="http://jeffreybreen.files.wordpress.com/2011/05/xau.png?w=300&#038;h=240" alt="" title="Gold (XAU)" width="300" height="240" class="alignnone size-medium wp-image-275" /></a></p>
<p><pre class="brush: r; light: true;">
chartSeries(XAGUSD, theme=&quot;white&quot;)
</pre><br />
<a href="http://jeffreybreen.files.wordpress.com/2011/05/xag.png"><img src="http://jeffreybreen.files.wordpress.com/2011/05/xag.png?w=300&#038;h=240" alt="" title="Silver (XAG)" width="300" height="240" class="alignnone size-medium wp-image-274" /></a></p>
<p>Yup &#8212; that&#8217;s quite a shellacking for silver.</p>
<p>Now I tend to be a ggplot2 guy myself, and I have never actually worked with <code>xts</code> or <code>zoo</code> objects before, but it&#8217;s pretty easy to get them into a suitable <code>data.frame</code>:</p>
<p><pre class="brush: r; light: true;">
silver = data.frame(XAGUSD)
silver$date = as.Date(rownames(silver))
colnames(silver)[1] = 'price'

library(ggplot2)
ggplot(data=silver, aes(x=date, y=price)) + geom_line() + theme_bw()
</pre><br />
<a href="http://jeffreybreen.files.wordpress.com/2011/05/ggplot_xag.png"><img src="http://jeffreybreen.files.wordpress.com/2011/05/ggplot_xag.png?w=300&#038;h=240" alt="" title="ggplot" width="300" height="240" class="alignnone size-medium wp-image-273" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/271/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=271&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/05/07/quantmod-silver-prices/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>

		<media:content url="http://jeffreybreen.files.wordpress.com/2011/05/xau.png?w=300" medium="image">
			<media:title type="html">Gold (XAU)</media:title>
		</media:content>

		<media:content url="http://jeffreybreen.files.wordpress.com/2011/05/xag.png?w=300" medium="image">
			<media:title type="html">Silver (XAG)</media:title>
		</media:content>

		<media:content url="http://jeffreybreen.files.wordpress.com/2011/05/ggplot_xag.png?w=300" medium="image">
			<media:title type="html">ggplot</media:title>
		</media:content>
	</item>
		<item>
		<title>Slides: &#8220;Accessing Databases from R&#8221; #rstats</title>
		<link>http://jeffreybreen.wordpress.com/2011/05/07/slides-accessing-databases-from-r-rstats/</link>
		<comments>http://jeffreybreen.wordpress.com/2011/05/07/slides-accessing-databases-from-r-rstats/#comments</comments>
		<pubDate>Sun, 08 May 2011 02:55:57 +0000</pubDate>
		<dc:creator>Jeffrey Breen</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[DBI]]></category>
		<category><![CDATA[Greater Boston useR Group]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[ODBC]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[RJDBC]]></category>
		<category><![CDATA[RMySQL]]></category>
		<category><![CDATA[RODBC]]></category>
		<category><![CDATA[RPostgreSQL]]></category>
		<category><![CDATA[RSQLite]]></category>
		<category><![CDATA[slides]]></category>
		<category><![CDATA[sqldf]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://jeffreybreen.wordpress.com/?p=259</guid>
		<description><![CDATA[For the past few meetings of the Greater Boston useR Group, we have been opened with an introductory &#8220;useR Vignette&#8221; talk on a topic which may be helpful for new R users. This week, I presented an overview of accessing databases from R. Several people have tweeted and blogged nice things about my talk and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=259&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For the past few meetings of the <a href="http://www.meetup.com/Boston-useR/">Greater Boston useR Group</a>, we have been opened with an introductory &#8220;useR Vignette&#8221; talk on a topic which may be helpful for new R users. This week, I presented an overview of accessing databases from R. <a href="http://twitter.com/#!/revodavid/status/66190168515813376">Several people</a> <a href="http://twitter.com/#!/cdhowe/status/66276832932139009">have tweeted</a> and <a href="http://blog.revolutionanalytics.com/2011/05/how-to-access-databases-from-r.html">blogged</a> nice things</a> about my talk<br />
and <a href="http://twitter.com/#!/genetics_blog/status/66293594423705600">have asked for the slides</a>, so here they are, via Slideshare:</p>
<iframe src='http://www.slideshare.net/slideshow/embed_code/7862491' width='780' height='639'></iframe>
<p>The final slide includes the code which I used to create and populate the &#8216;testdb&#8217; database I used for my examples. I have duplicated it here as it&#8217;s a nice, quick example of using DBI to store an R <code>data.frame</code> in a database:</p>
<p>First, create new database &amp; user in MySQL:</p>
<p><pre class="brush: sql; light: true;">
mysql&gt; create database testdb;
mysql&gt; grant all privileges on testdb.* to 'testuser'@'localhost' identified by 'testpass';
mysql&gt; flush privileges;
</pre></p>
<p>In R, load the &#8220;mtcars&#8221; <code>data.frame</code>, clean it up, and write it to a new &#8220;motortrend&#8221; table:</p>
<p><pre class="brush: r; light: true;">
library(stringr)
library(RMySQL)

data(mtcars)

# car name is data.frame's rownames. Let's split into manufacturer and model columns:
mtcars$mfg = str_split_fixed(rownames(mtcars), ' ', 2)[,1]
mtcars$mfg[mtcars$mfg=='Merc'] = 'Mercedes'
mtcars$model = str_split_fixed(rownames(mtcars), ' ', 2)[,2]

# connect to local MySQL database (host='localhost' by default)
con = dbConnect(&quot;MySQL&quot;, &quot;testdb&quot;, username=&quot;testuser&quot;, password=&quot;testpass&quot;)

dbWriteTable(con, 'motortrend', mtcars)

dbDisconnect(con)
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jeffreybreen.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jeffreybreen.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jeffreybreen.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jeffreybreen.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jeffreybreen.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jeffreybreen.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jeffreybreen.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jeffreybreen.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jeffreybreen.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jeffreybreen.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jeffreybreen.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jeffreybreen.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jeffreybreen.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jeffreybreen.wordpress.com/259/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jeffreybreen.wordpress.com&amp;blog=1195963&amp;post=259&amp;subd=jeffreybreen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jeffreybreen.wordpress.com/2011/05/07/slides-accessing-databases-from-r-rstats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78f86d3c15d7ca35a86e36937b01cc2d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jeffreybreen</media:title>
		</media:content>
	</item>
	</channel>
</rss>
