<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>R-statistics blog</title>
	
	<link>http://www.r-statistics.com</link>
	<description>Writing about statistics with R, and open source stuff (software, data, community)</description>
	<lastBuildDate>Wed, 09 May 2012 06:58:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/R-statistics" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="r-statistics" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">R-statistics</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>data.table version 1.8.1 – now allowed numeric columns and big-number (via bit64) in keys!</title>
		<link>http://www.r-statistics.com/2012/05/data-table-version-1-8-1-now-allowed-numeric-columns-and-big-number-via-bit64-in-keys/</link>
		<comments>http://www.r-statistics.com/2012/05/data-table-version-1-8-1-now-allowed-numeric-columns-and-big-number-via-bit64-in-keys/#comments</comments>
		<pubDate>Wed, 09 May 2012 06:38:25 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[data.table]]></category>
		<category><![CDATA[HPC]]></category>
		<category><![CDATA[indexing]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60671</guid>
		<description><![CDATA[This is a guest post written by Branson Owen, an enthusiastic R and data.table user. Wow, a long time desired feature of data.table finally came true in version 1.8.1! data.table now allowed numeric columns and big number (via bit64) in &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2012/05/data-table-version-1-8-1-now-allowed-numeric-columns-and-big-number-via-bit64-in-keys/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>This is a guest post written by Branson Owen, an enthusiastic R and data.table user.</strong></p>
<div>
<p>Wow, a long time desired feature of data.table finally came true in version 1.8.1! data.table now allowed numeric columns and big number (via bit64) in keys! This is quite a big thing to me and I believe to many other R users too. Now I can hardly think any weakiness of data.table. Oh, did I mention it also started to support character column in the keys (rather than coerce to factor)?</p>
<p>For people who are not familiar with but interested in data.table package, <strong>data.table is an enhanced data.frame for high-speed indexing, ordered joins, assignment, grouping and list columns in a short and flexible syntax.</strong> You can take a look at some task examples here:</p>
<div>
<ul>
<li><a href="http://stackoverflow.com/questions/4322219/whats-the-fastest-way-to-merge-join-data-frames-in-r/4483202#4483202" target="_blank">What&#8217;s the fastest way to merge/join data.frames in R</a></li>
<li><a href="http://zvfak.blogspot.com/2011/03/applying-functions-on-groups-sqldf-plyr.html" target="_blank">Fastest way to apply functions on groups</a></li>
<li><a href="http://cran.r-project.org/web/packages/data.table/vignettes/datatable-timings.pdf" target="_blank">Timings of common tasks using the data.table</a></li>
</ul>
</div>
<div></div>
<h3>News from datatable-help mailing list:</h3>
<p>* New functions chmatch() and %chin%, faster versions of match() and %in% for character vectors. They are about 4 times faster than match() on the example in ?chmatch.</p>
<p>* New function set(DT,i,j,value) allows fast assignment to elements of DT.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60671code3');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60671code3'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p606713"><td class="code" id="p60671code3"><pre class="rsplus" style="font-family:monospace;">&nbsp;
M <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">matrix</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span>,<span style="color: #0000FF; font-weight: bold;">nrow</span><span style="color: #080;">=</span><span style="color: #ff0000;">100000</span>,<span style="color: #0000FF; font-weight: bold;">ncol</span><span style="color: #080;">=</span><span style="color: #ff0000;">100</span><span style="color: #080;">&#41;</span>
DF <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">as.<span style="">data</span>.<span style="">frame</span></span><span style="color: #080;">&#40;</span>M<span style="color: #080;">&#41;</span>
DT <span style="color: #080;">=</span> as.<span style="">data</span>.<span style="">table</span><span style="color: #080;">&#40;</span>M<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">system.<span style="">time</span></span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">for</span> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">1000</span><span style="color: #080;">&#41;</span> DF<span style="color: #080;">&#91;</span>i,1L<span style="color: #080;">&#93;</span> <span style="color: #080;">&amp;</span>lt<span style="color: #080;">;-</span> i<span style="color: #080;">&#41;</span> <span style="color: #228B22;"># 591.000s</span>
<span style="color: #0000FF; font-weight: bold;">system.<span style="">time</span></span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">for</span> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">1000</span><span style="color: #080;">&#41;</span> DT<span style="color: #080;">&#91;</span>i,V1<span style="color: #080;">:=</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># 1.158s</span>
<span style="color: #0000FF; font-weight: bold;">system.<span style="">time</span></span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">for</span> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">1000</span><span style="color: #080;">&#41;</span> M<span style="color: #080;">&#91;</span>i,1L<span style="color: #080;">&#93;</span> <span style="color: #080;">&amp;</span>lt<span style="color: #080;">;-</span> i<span style="color: #080;">&#41;</span> <span style="color: #228B22;"># 0.016s</span>
<span style="color: #0000FF; font-weight: bold;">system.<span style="">time</span></span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">for</span> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">1000</span><span style="color: #080;">&#41;</span> set<span style="color: #080;">&#40;</span>DT,i,1L,i<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># 0.027s</span></pre></td></tr></table></div>

<p>* Numeric columns (type &#8216;double&#8217;) are now allowed in keys and ad hoc by. Other types which use &#8216;double&#8217; (such as POSIXct and bit64) can now be fully supported.</p>
<p>For advanced and creative users, it also officially supported list columns awhile ago (rather than support it by accident). For example, your column could be a list of vectors, where each of the vector has different length. This can allow very flexible and creative ways to manipulate data.</p>
<p>The code example below use &#8220;function column&#8221;, i.e. a list of functions</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60671code4');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60671code4'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p606714"><td class="code" id="p60671code4"><pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> DT <span style="color: #080;">=</span> data.<span style="">table</span><span style="color: #080;">&#40;</span>ID<span style="color: #080;">=</span><span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">4</span>,A<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">rnorm</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">4</span><span style="color: #080;">&#41;</span>,B<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">rnorm</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">4</span><span style="color: #080;">&#41;</span>,fn<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">list</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">min</span>,<span style="color: #0000FF; font-weight: bold;">max</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">str</span><span style="color: #080;">&#40;</span>DT<span style="color: #080;">&#41;</span>
Classes ‘data.<span style="">table</span>’ and <span style="color: #ff0000;">'data.frame'</span><span style="color: #080;">:</span> <span style="color: #ff0000;">4</span> obs. <span style="">of</span> <span style="color: #ff0000;">4</span> variables<span style="color: #080;">:</span>
$ ID<span style="color: #080;">:</span> int <span style="color: #ff0000;">1</span> <span style="color: #ff0000;">2</span> <span style="color: #ff0000;">3</span> <span style="color: #ff0000;">4</span>
$ A <span style="color: #080;">:</span> num <span style="color: #080;">-</span><span style="color: #ff0000;">0.7135</span> <span style="color: #080;">-</span><span style="color: #ff0000;">2.5217</span> <span style="color: #ff0000;">0.0265</span> <span style="color: #ff0000;">1.0102</span>
$ B <span style="color: #080;">:</span> num <span style="color: #080;">-</span><span style="color: #ff0000;">0.4116</span> <span style="color: #ff0000;">0.4032</span> <span style="color: #ff0000;">0.1098</span> <span style="color: #ff0000;">0.0669</span>
$ fn<span style="color: #080;">:</span>List of <span style="color: #ff0000;">4</span>
..$ <span style="color: #080;">:</span><span style="color: #0000FF; font-weight: bold;">function</span> <span style="color: #080;">&#40;</span>..., na.<span style="">rm</span> <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span>
..$ <span style="color: #080;">:</span><span style="color: #0000FF; font-weight: bold;">function</span> <span style="color: #080;">&#40;</span>..., na.<span style="">rm</span> <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span>
..$ <span style="color: #080;">:</span><span style="color: #0000FF; font-weight: bold;">function</span> <span style="color: #080;">&#40;</span>..., na.<span style="">rm</span> <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span>
..$ <span style="color: #080;">:</span><span style="color: #0000FF; font-weight: bold;">function</span> <span style="color: #080;">&#40;</span>..., na.<span style="">rm</span> <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #080;">&gt;</span> DT<span style="color: #080;">&#91;</span>,fn<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#40;</span>A,B<span style="color: #080;">&#41;</span>,<span style="color: #0000FF; font-weight: bold;">by</span><span style="color: #080;">=</span>ID<span style="color: #080;">&#93;</span>
ID V1
<span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span>,<span style="color: #080;">&#93;</span> <span style="color: #ff0000;">1</span> <span style="color: #080;">-</span><span style="color: #ff0000;">0.71352508</span>
<span style="color: #080;">&#91;</span><span style="color: #ff0000;">2</span>,<span style="color: #080;">&#93;</span> <span style="color: #ff0000;">2</span> <span style="color: #ff0000;">0.40322625</span>
<span style="color: #080;">&#91;</span><span style="color: #ff0000;">3</span>,<span style="color: #080;">&#93;</span> <span style="color: #ff0000;">3</span> <span style="color: #ff0000;">0.02648949</span>
<span style="color: #080;">&#91;</span><span style="color: #ff0000;">4</span>,<span style="color: #080;">&#93;</span> <span style="color: #ff0000;">4</span> <span style="color: #ff0000;">1.01022266</span></pre></td></tr></table></div>

<p>[ref] <a href="https://r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=1302&amp;group_id=240&amp;atid=978">https://r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=1302&amp;group_id=240&amp;atid=978</a></p>
<p>&nbsp;</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/05/data-table-version-1-8-1-now-allowed-numeric-columns-and-big-number-via-bit64-in-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speed up your R code using a just-in-time (JIT) compiler</title>
		<link>http://www.r-statistics.com/2012/04/speed-up-your-r-code-using-a-just-in-time-jit-compiler/</link>
		<comments>http://www.r-statistics.com/2012/04/speed-up-your-r-code-using-a-just-in-time-jit-compiler/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 23:34:21 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[jit]]></category>
		<category><![CDATA[Julia]]></category>
		<category><![CDATA[just in time]]></category>
		<category><![CDATA[just-in-time compilation]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[statistical programing]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60633</guid>
		<description><![CDATA[This post is about speeding up your R code using the JIT (just in time) compilation capabilities offered by the new (well, now a year old) {compiler} package. Specifically, dealing with the practical difference between enableJIT and the cmpfun functions. &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2012/04/speed-up-your-r-code-using-a-just-in-time-jit-compiler/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>This post is about speeding up your R code using the JIT (just in time) compilation capabilities offered by the new (well, <a href="http://onertipaday.blogspot.com/2011/04/r-2130-is-released.html">now a year old</a>) <a href="http://stat.ethz.ch/R-manual/R-devel/library/compiler/html/compile.html">{compiler} package</a>. Specifically, dealing with the practical difference between <em>enableJIT</em> and the <em>cmpfun</em> functions.</p>
<p>If you do not want to read much, you can just skip to the example part.</p>
<p>As always, I welcome any comments to this post, and hope to update it when future JIT solutions will come along.</p>
<p><span id="more-60633"></span></p>
<h3>Prelude: what is JIT</h3>
<p><a href="http://en.wikipedia.org/wiki/Just-in-time_compilation">Just-in-time compilation (JIT)</a>:</p>
<blockquote><p>is a method to improve the runtime performance of computer programs. Historically, computer programs had two modes of runtime operation, either interpreted or static (ahead-of-time) compilation. Interpreted code is translated from a high-level language to a machine code continuously during every execution, whereas statically compiled code is translated into machine code before execution, and only requires this translation once.<br />
JIT compilers represent a hybrid approach, with <strong>translation occurring continuously, as with interpreters, but with caching of translated code to minimize performance degradation</strong>. It also offers other advantages over statically compiled code at development time, such as handling of late-bound data types and the ability to enforce security guarantees.</p></blockquote>
<h3>JIT in R</h3>
<p>To this date, there are two R packages that offers Just-in-time compilation to R users: the <a href="http://www.milbo.users.sonic.net/ra/jit.html">{jit} package</a> (through The Ra Extension to R), and the <a href="http://stat.ethz.ch/R-manual/R-devel/library/compiler/html/compile.html">{compiler} package</a> (which now comes bundled with any new R release, since R 2.13).</p>
<h4>The {jit} package</h4>
<p><strong>The <a href="http://www.milbo.users.sonic.net/ra/jit.html">{jit} package</a>,</strong> created by <a href="http://www.milbo.users.sonic.net/">Stephen Milborrow</a>, provides just-in-time compilation of R loops and arithmetic expressions in loops, enabling such code to run much faster (speeding up loops between <a href="http://www.milbo.users.sonic.net/ra/times9.html">10 to 20 times faster</a>). However, the drawback is that in order to use {jit}, you will need to use it through &#8220;<a href="http://www.milbo.users.sonic.net/ra/">the Ra Extension to R</a>&#8220; (<a href="http://www.milbo.users.sonic.net/ra/README-RaWin32.html">Ra is like R</a>, only that it allows using the {jit} package). Sadly, <strong>the {jit} package will have no effect under standard R</strong>.  The package was not updated since 2011-08-27, and I am curious to see how its future might unfold (either continue on, merge with some other project, or sadly will go out of use).</p>
<h4>The {compiler} package</h4>
<p><strong>The <a href="http://stat.ethz.ch/R-manual/R-devel/library/compiler/html/compile.html">{compiler} package</a></strong>, created by <a href="http://www.cs.uiowa.edu/~luke/">Luke Tierney</a>, offers a <a href="http://en.wikipedia.org/wiki/Bytecode">byte-code</a> compiler for R:</p>
<blockquote><p><strong>A byte code compiler</strong> translates a complex high-level language like Lisp into a very simple language that can be interpreted by a very fast byte code interpreter, or virtual machine. The internal representation of this simple language is a string of bytes, hence the name byte code. The compilation process eliminates a number of costly operations the interpreter has to perform, including variable lookup and setting up exits for nonlocal transfers of control. It also performs some inlining and makes the language tail-recursive. This means that tail calls are compiled as jumps and therefore iterations can be implemented using recursion.<em> (the <a href="http://www.divms.uiowa.edu/~luke/xls/interface98/paper/node3.html">source</a> of this quote)</em></p>
<p><strong>The compiler</strong> produces code for a virtual machine that is then executed by a virtual machine runtime system.  The virtual machine is a stack based machine. Thus instructions for the virtual machine take arguments off a stack and may leave one or more results on the stack. Byte code objects consists of an integer vector representing instruction opcodes and operands, and a generic vector representing a constant pool. The compiler is implemented almost entirely in R, with just a few support routines in C to manage compiled code objects.<br />
The virtual machine instruction set is designed to allow much of the interpreter internals to be re-used. In particular, for now the mechanism for calling functions of all types from compiled code remains the same as the function calling mechanism for interpreted code. <em> (the <a href="http://www.divms.uiowa.edu/~luke/R/compiler/compiler.pdf">source </a>of this quote)</em></p></blockquote>
<p>From the perspective of using JIT with R, the above means that the {compiler} package does not offer a jit compiler to a machine code, but it does offer it in order to turn it into byte code.</p>
<p>The byte compiler was first introduced with R 2.13, and <a href="http://blog.revolutionanalytics.com/2011/08/with-byte-compiler-r-214-will-be-even-faster.html">starting with R 2.14</a>, all of the standard functions and packages in R were pre-compiled into byte-code.  The benefit in speed depends on the specific function but code&#8217;s performance can improve up by a factor of 2x times or more.</p>
<p>In some early experiments, <a href="http://dirk.eddelbuettel.com">Dirk Eddelbuettel</a> (our community&#8217;s <a href="http://cran.r-project.org/web/views/HighPerformanceComputing.html">R&#8217;s HPC</a> guru) looked at what the {compiler} package can offer us when using the <em>cmpfun()</em> function.  e showed that <a href="http://dirk.eddelbuettel.com/blog/2011/04/12/">the performance gain for various made-up functions</a> can range between 2x to 5x times faster running time.  This is great for the small amount of work (e.g: code modification) it requires on our part, but just in order to give it some perspective, using <a href="http://www.milbo.users.sonic.net/ra/times9.html">Ra can speed up your code</a> to be up to 25x times faster (as was also <a href="http://www.divms.uiowa.edu/~luke/talks/useR10.pdf">mentioned by Tierney himself in slides from 2010</a>, see slide 20).  Moreover, by combining C/C++ code with R code (for example, through the {<a href="http://cran.r-project.org/web/packages/Rcpp/index.html">Rcpp</a>} and {<a href="http://cran.r-project.org/web/packages/inline/index.html">Inline</a>} packages) you can improve your code&#8217;s running time by a factor of 80 (or even almost 120 to the worst manual implementation) relative to interpreted code.  But to be fair to R, the code that is used for such examples is often unrealistic code examples that is often not representative of real R work. Thus, effective speed gains can be expected to be smaller for all of the above solutions.</p>
<p>If you want to learn more on the {compiler} package, Prof Tierney wrote a massive <a href="http://www.divms.uiowa.edu/~luke/R/compiler/compiler.pdf">100+ page paper on R&#8217;s byte-code compiler</a>, which also includes points for future research and development.</p>
<h3>Using the {compiler} package as a JIT for R</h3>
<h4>Description</h4>
<p><em>(From the manual &#8220;<a href="http://www.divms.uiowa.edu/~luke/R/compiler/compiler.pdf">A Byte Code Compiler for R</a>&#8220;)</em></p>
<p>JIT compilation, through the {compiler} package, can be enabled from within an active R session by calling the <em>enableJIT()</em> function with a non-negative integer argument (from 0 to 3), or by starting R with the environment variable R_ENABLE_JIT set to a non-negative integer.  The possible values of the argument to enableJIT and their meanings are:</p>
<ul>
<li><strong>0</strong> - turn off JIT</li>
<li><strong>1</strong> - compile closures before they are called the first time</li>
<li><strong>2</strong> - same as 1, plus compile closures before duplicating (useful for packages that store closures in lists, like lattice)</li>
<li><strong>3</strong> - same as 2, plus compile all for(), while(), and repeat() loops before executing.</li>
</ul>
<p>R may initially be somewhat sluggish if JIT is enabled and base and recommended packages have not been pre-compiled as almost everything will initially need some compilation.</p>
<h4>Example</h4>
<p>The following example is an adaptation of the code taken from the <a href="http://stat.ethz.ch/R-manual/R-devel/library/compiler/html/compile.html"><em>?compile</em> help file</a>.</p>
<p>Let us start by defining two functions we will use for our example:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60633code12');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60633code12'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6063312"><td class="code" id="p60633code12"><pre class="rsplus" style="font-family:monospace;">&nbsp;
<span style="color: #228B22;">##### Functions #####</span>
&nbsp;
is.<span style="">compile</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>func<span style="color: #080;">&#41;</span>
<span style="color: #080;">&#123;</span>
	<span style="color: #228B22;"># this function lets us know if a function has been byte-coded or not</span>
	<span style="color: #228B22;">#If you have a better idea for how to do this - please let me know...</span>
    <span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">class</span><span style="color: #080;">&#40;</span>func<span style="color: #080;">&#41;</span> <span style="color: #080;">!=</span> <span style="color: #ff0000;">&quot;function&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF; font-weight: bold;">stop</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;You need to enter a function&quot;</span><span style="color: #080;">&#41;</span>
    last_2_lines <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">tail</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">capture.<span style="">output</span></span><span style="color: #080;">&#40;</span>func<span style="color: #080;">&#41;</span>,<span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span>
    <span style="color: #0000FF; font-weight: bold;">any</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">grepl</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;bytecode:&quot;</span>, last_2_lines<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># returns TRUE if it finds the text &quot;bytecode:&quot; in any of the last two lines of the function's print</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;"># old R version of lapply</span>
slow_func <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>X, FUN, ...<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
   FUN <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">match.<span style="">fun</span></span><span style="color: #080;">&#40;</span>FUN<span style="color: #080;">&#41;</span>
   <span style="color: #0000FF; font-weight: bold;">if</span> <span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">is.<span style="">list</span></span><span style="color: #080;">&#40;</span>X<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
    X <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">as.<span style="">list</span></span><span style="color: #080;">&#40;</span>X<span style="color: #080;">&#41;</span>
   rval <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">vector</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;list&quot;</span>, <span style="color: #0000FF; font-weight: bold;">length</span><span style="color: #080;">&#40;</span>X<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
   <span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #0000FF; font-weight: bold;">seq</span><span style="color: #080;">&#40;</span>along <span style="color: #080;">=</span> X<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
    rval<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">list</span><span style="color: #080;">&#40;</span>FUN<span style="color: #080;">&#40;</span>X<span style="color: #080;">&#91;</span><span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span><span style="color: #080;">&#93;</span>, ...<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
   <span style="color: #0000FF; font-weight: bold;">names</span><span style="color: #080;">&#40;</span>rval<span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">names</span><span style="color: #080;">&#40;</span>X<span style="color: #080;">&#41;</span>          <span style="color: #228B22;"># keep `names' !</span>
   <span style="color: #0000FF; font-weight: bold;">return</span><span style="color: #080;">&#40;</span>rval<span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;"># Compiled versions</span>
<span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>compiler<span style="color: #080;">&#41;</span>
slow_func_compiled <span style="color: #080;">&lt;-</span> cmpfun<span style="color: #080;">&#40;</span>slow_func<span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>Notice how in the last line of code we manually byte-compile our slow function.  Next, let&#8217;s define a function that will run the slow function (the raw and the complied versions) many times, and measure the time it takes to run each:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60633code13');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60633code13'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6063313"><td class="code" id="p60633code13"><pre class="rsplus" style="font-family:monospace;">&nbsp;
fo <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF; font-weight: bold;">for</span> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">1000</span><span style="color: #080;">&#41;</span> slow_func<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">100</span>, <span style="color: #0000FF; font-weight: bold;">is.<span style="">null</span></span><span style="color: #080;">&#41;</span>
fo_c <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF; font-weight: bold;">for</span> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">1000</span><span style="color: #080;">&#41;</span> slow_func_compiled<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">100</span>, <span style="color: #0000FF; font-weight: bold;">is.<span style="">null</span></span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #0000FF; font-weight: bold;">system.<span style="">time</span></span><span style="color: #080;">&#40;</span>fo<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">system.<span style="">time</span></span><span style="color: #080;">&#40;</span>fo_c<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;"># &gt; system.time(fo())</span>
   <span style="color: #228B22;"># user  system elapsed </span>
   <span style="color: #228B22;"># 0.54    0.00    0.57 </span>
<span style="color: #228B22;"># &gt; system.time(fo_c())</span>
   <span style="color: #228B22;"># user  system elapsed </span>
   <span style="color: #228B22;"># 0.17    0.00    0.17</span></pre></td></tr></table></div>

<p>We see in this example how using the byte compiler on &#8220;slow_func&#8221; gave us a bit over 3x times speed gain.  What will happen if we used the <em>cmpfun()</em> function on the function &#8220;fo&#8221; itself?  Let&#8217;s check:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60633code14');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60633code14'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6063314"><td class="code" id="p60633code14"><pre class="rsplus" style="font-family:monospace;">fo_compiled <span style="color: #080;">&lt;-</span> cmpfun<span style="color: #080;">&#40;</span>fo<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">system.<span style="">time</span></span><span style="color: #080;">&#40;</span>fo_compiled<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># doing this, will not change the speed at all:</span>
<span style="color: #228B22;">#   user  system elapsed </span>
<span style="color: #228B22;">#   0.58    0.00    0.58</span></pre></td></tr></table></div>

<p>We can see that we did not get any speed gain from this operation, why is that?  The reason is that the slow function (slow_func) is still not compiled:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60633code15');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60633code15'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6063315"><td class="code" id="p60633code15"><pre class="rsplus" style="font-family:monospace;">is.<span style="">compile</span><span style="color: #080;">&#40;</span>slow_func<span style="color: #080;">&#41;</span>
<span style="color: #228B22;"># [1] FALSE</span>
is.<span style="">compile</span><span style="color: #080;">&#40;</span>fo<span style="color: #080;">&#41;</span>
<span style="color: #228B22;"># [1] FALSE</span>
is.<span style="">compile</span><span style="color: #080;">&#40;</span>fo_compiled<span style="color: #080;">&#41;</span>
<span style="color: #228B22;"># [1] TRUE</span></pre></td></tr></table></div>

<p>The <em>cmpfun()</em> function only compiled the wrapping function fo (fo_compiled), but not the functions nested within it (slow_func).  And this is where the enableJIT() function kicks in:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60633code16');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60633code16'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6063316"><td class="code" id="p60633code16"><pre class="rsplus" style="font-family:monospace;">enableJIT<span style="color: #080;">&#40;</span><span style="color: #ff0000;">3</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">system.<span style="">time</span></span><span style="color: #080;">&#40;</span>fo<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">#   user  system elapsed </span>
<span style="color: #228B22;">#   0.19    0.00    0.18</span></pre></td></tr></table></div>

<p>We can see that &#8220;suddenly&#8221; fo has become much faster.  The reason is because turning the JIT on (using enableJIT(3)), basically started turning any function we run into byte-code.  So if we now check again, we find that:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60633code17');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60633code17'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6063317"><td class="code" id="p60633code17"><pre class="rsplus" style="font-family:monospace;">is.<span style="">compile</span><span style="color: #080;">&#40;</span>fo<span style="color: #080;">&#41;</span> 
<span style="color: #228B22;"># [1] TRUE # when it previously was not compiled, only fo_compiled was...</span>
is.<span style="">compile</span><span style="color: #080;">&#40;</span>slow_func<span style="color: #080;">&#41;</span>
<span style="color: #228B22;"># [1] TRUE # when it previously was not compiled, only slow_func_compiled was...</span></pre></td></tr></table></div>

<p>This means that <strong>if you want to have as little modification to your code as possible</strong>, instead of going through every function you use and run <em>cmpfun()</em> on it, <strong>you can simply run the following code once, in the beginning of your code:</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60633code18');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60633code18'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6063318"><td class="code" id="p60633code18"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>compiler<span style="color: #080;">&#41;</span>
enableJIT<span style="color: #080;">&#40;</span><span style="color: #ff0000;">3</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>And you will get the speed gains the byte compiler has to offer your code.</p>
<p>On a side note, we can now turn the JIT back off using &#8220;enableJIT(0)&#8221;, but it has still already compiled the inner functions (for example fo and slow_func).  If we want to un-compile them, we will have to re-create these functions again (run the code that produced them in the first place).</p>
<p><strong>To conclude</strong>: in this post I have discussed the current state of just-in-time compilation of R code, and shown how to use the {compiler} package for using JIT in R.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/04/speed-up-your-r-code-using-a-just-in-time-jit-compiler/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Do more with dates and times in R with lubridate 1.1.0</title>
		<link>http://www.r-statistics.com/2012/03/do-more-with-dates-and-times-in-r-with-lubridate-1-1-0/</link>
		<comments>http://www.r-statistics.com/2012/03/do-more-with-dates-and-times-in-r-with-lubridate-1-1-0/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 09:13:43 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[dates]]></category>
		<category><![CDATA[Garrett Grolemund]]></category>
		<category><![CDATA[Garrett Groleund]]></category>
		<category><![CDATA[Hadley Wickham]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[lubridate]]></category>
		<category><![CDATA[package]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60602</guid>
		<description><![CDATA[This is a guest post by Garrett Grolemund (mentored by Hadley Wickham) Lubridate is an R package that makes it easier to work with dates and times. The newest release of lubridate (v 1.1.0) comes with even more tools and &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2012/03/do-more-with-dates-and-times-in-r-with-lubridate-1-1-0/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>This is a guest post by Garrett Grolemund (mentored by <a href="http://had.co.nz/">Hadley Wickham</a>)</p>
<p>Lubridate is an R package that makes it easier to work with dates and times. The newest release of lubridate (v 1.1.0) comes with even more tools and some significant changes over past versions. Below is a concise tour of some of the things lubridate can do for you. At the end of this post, I list some of the differences between lubridate (v 0.2.4) and lubridate (v 1.1.0). If you are an old hand at lubridate, please read this section to avoid surprises!</p>
<p>Lubridate was created by Garrett Grolemund and Hadley Wickham.</p>
<h2>Parsing dates and times</h2>
<p>Getting R to agree that your data contains the dates and times you think it does can be a bit tricky. Lubridate simplifies that. Identify the order in which the year, month, and day appears in your dates. Now arrange “y”, “m”, and “d” in the same order. This is the name of the function in lubridate that will parse your dates. For example,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code36');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code36'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060236"><td class="code" id="p60602code36"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">library</span><span style="color: #080;">&#40;</span>lubridate<span style="color: #080;">&#41;</span>
ymd<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;20110604&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> mdy<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;06-04-2011&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> dmy<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;04/06/2011&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2011-06-04 UTC&quot;</span>
<span style="color: #228B22;">## &quot;2011-06-04 UTC&quot;</span>
<span style="color: #228B22;">## &quot;2011-06-04 UTC&quot;</span></pre></td></tr></table></div>

<p>Parsing functions automatically handle a wide variety of formats and separators, which simplifies the parsing process.</p>
<p>If your date includes time information, add h, m, and/or s to the name of the function. ymd_hms() is probably the most common date time format. To read the dates in with a certain time zone, supply the official name of that time zone in the tz argument.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code37');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code37'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060237"><td class="code" id="p60602code37"><pre class="rsplus" style="font-family:monospace;">arrive <span style="color: #080;">&lt;-</span> ymd_hms<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;2011-06-04 12:00:00&quot;</span>, tz <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;Pacific/Auckland&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2011-06-04 12:00:00 NZST&quot;</span>
leave <span style="color: #080;">&lt;-</span> ymd_hms<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;2011-08-10 14:00:00&quot;</span>, tz <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;Pacific/Auckland&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2011-08-10 14:00:00 NZST&quot;</span></pre></td></tr></table></div>

<h2>Setting and Extracting information</h2>
<p>Extract information from date times with the functions second(), minute(), hour(), day(), wday(), yday(), week(), month(), year(), and tz(). You can also use each of these to set (i.e, change) the given information. Notice that this will alter the date time. wday() and month() have an optional label argument, which replaces their numeric output with the name of the weekday or month.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code38');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code38'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060238"><td class="code" id="p60602code38"><pre class="rsplus" style="font-family:monospace;">second<span style="color: #080;">&#40;</span>arrive<span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## 0</span>
second<span style="color: #080;">&#40;</span>arrive<span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span> <span style="color: #ff0000;">25</span>
arrive
<span style="color: #228B22;">## &quot;2011-06-04 12:00:25 NZST&quot;</span>
second<span style="color: #080;">&#40;</span>arrive<span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span> <span style="color: #ff0000;">0</span>
wday<span style="color: #080;">&#40;</span>arrive<span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## 7</span>
wday<span style="color: #080;">&#40;</span>arrive, label <span style="color: #080;">=</span> TRUE<span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## Sat</span></pre></td></tr></table></div>

<h2>Time Zones</h2>
<p>There are two very useful things to do with dates and time zones. First, display the same moment in a different time zone. Second, create a new moment by combining a given clock time with a new time zone. These are accomplished by with_tz() and force_tz().</p>
<p>For example, I spent last summer researching in Auckland, New Zealand. I arranged to meet with my advisor, Hadley, over skype at 9:00 in the morning Auckland time. What time was that for Hadley who was back in Houston, TX?</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code39');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code39'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060239"><td class="code" id="p60602code39"><pre class="rsplus" style="font-family:monospace;">meeting <span style="color: #080;">&lt;-</span> ymd_hms<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;2011-07-01 09:00:00&quot;</span>, tz <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;Pacific/Auckland&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2011-07-01 09:00:00 NZST&quot;</span>
with_tz<span style="color: #080;">&#40;</span>meeting, <span style="color: #ff0000;">&quot;America/Chicago&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2011-06-30 16:00:00 CDT&quot;</span></pre></td></tr></table></div>

<p>So the meetings occurred at 4:00 Hadley’s time (and the day before no less). Of course, this was the same actual moment of time as 9:00 in New Zealand. It just appears to be a different day due to the curvature of the Earth.</p>
<p>What if Hadley made a mistake and signed on at 9:00 his time? What time would it then be my time?</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code40');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code40'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060240"><td class="code" id="p60602code40"><pre class="rsplus" style="font-family:monospace;">mistake <span style="color: #080;">&lt;-</span> force_tz<span style="color: #080;">&#40;</span>meeting, <span style="color: #ff0000;">&quot;America/Chicago&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2011-07-01 09:00:00 CDT&quot;</span>
with_tz<span style="color: #080;">&#40;</span>mistake, <span style="color: #ff0000;">&quot;Pacific/Auckland&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2011-07-02 02:00:00 NZST&quot;</span></pre></td></tr></table></div>

<p>His call would arrive at 2:00 am my time! Luckily he never did that.</p>
<p><span id="more-60602"></span></p>
<h2>Time Intervals</h2>
<p>You can save an interval of time as an Interval class object. This is quite useful! For example, my stay in Auckland lasted from June 4 to August 10 (which we’ve already saved as arrive and leave). We can create this interval in one of two ways:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code41');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code41'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060241"><td class="code" id="p60602code41"><pre class="rsplus" style="font-family:monospace;">auckland <span style="color: #080;">&lt;-</span> interval<span style="color: #080;">&#40;</span>arrive, leave<span style="color: #080;">&#41;</span> 
<span style="color: #228B22;">## 2011-06-04 12:00:00 NZST--2011-08-10 14:00:00 NZST</span>
auckland <span style="color: #080;">&lt;-</span> arrive <span style="color: #080;">%--%</span> leave
<span style="color: #228B22;">## 2011-06-04 12:00:00 NZST--2011-08-10 14:00:00 NZST</span></pre></td></tr></table></div>

<p>My mentor at the University of Auckland, Chris, traveled to various conferences that year including the Joint Statistical Meetings (JSM). This took him out of the country from July 20 until the end of August.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code42');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code42'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060242"><td class="code" id="p60602code42"><pre class="rsplus" style="font-family:monospace;">jsm <span style="color: #080;">&lt;-</span> interval<span style="color: #080;">&#40;</span>ymd<span style="color: #080;">&#40;</span><span style="color: #ff0000;">20110720</span>, tz <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;Pacific/Auckland&quot;</span><span style="color: #080;">&#41;</span>, ymd<span style="color: #080;">&#40;</span><span style="color: #ff0000;">20110831</span>, tz <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;Pacific/Auckland&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>Will my visit overlap with and his travels? Yes.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code43');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code43'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060243"><td class="code" id="p60602code43"><pre class="rsplus" style="font-family:monospace;">int_overlaps<span style="color: #080;">&#40;</span>jsm, auckland<span style="color: #080;">&#41;</span> <span style="color: #228B22;">## TRUE</span></pre></td></tr></table></div>

<p>Then I better make hay while the sun shines! For what part of my visit will Chris be there?</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code44');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code44'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060244"><td class="code" id="p60602code44"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">setdiff</span><span style="color: #080;">&#40;</span>auckland, jsm<span style="color: #080;">&#41;</span> <span style="color: #228B22;">## 2011-06-04 12:00:00 NZST–2011-07-20 NZST</span></pre></td></tr></table></div>

<p>Other functions that work with intervals include int_start, int_end, int_flip, int_shift, int_aligns, union, intersect, and %within%.</p>
<h2>Arithmetic with date times</h2>
<p>Intervals are specific time spans (because they are tied to specific dates), but lubridate also supplies two general time span classes: durations and periods. Helper functions for creating periods are named after the units of time (plural). Helper functions for creating durations follow the same format but begin with a “d” (for duration) or, if you prefer, and “e” (for exact).</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code45');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code45'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060245"><td class="code" id="p60602code45"><pre class="rsplus" style="font-family:monospace;">minutes<span style="color: #080;">&#40;</span><span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># period</span>
<span style="color: #228B22;">## 2 minutes</span>
dminutes<span style="color: #080;">&#40;</span><span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># duration</span>
<span style="color: #228B22;">## 120s (~2 minutes)</span></pre></td></tr></table></div>

<p>Why two classes? Because the timeline is not as reliable as the number line. The durations class will always supply mathematically precise results. A duration year will <em>always</em> equal 365 days. Periods, on the other hand, fluctuate the same way the timeline does to give intuitive results. This makes them useful for modelling clock times. For example, durations will be honest in the face of a leap year, but periods may return what you want:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code46');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code46'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060246"><td class="code" id="p60602code46"><pre class="rsplus" style="font-family:monospace;">leap_year<span style="color: #080;">&#40;</span><span style="color: #ff0000;">2011</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## FALSE</span>
ymd<span style="color: #080;">&#40;</span><span style="color: #ff0000;">20110101</span><span style="color: #080;">&#41;</span> <span style="color: #080;">+</span> dyears<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2012-01-01 UTC&quot;</span>
ymd<span style="color: #080;">&#40;</span><span style="color: #ff0000;">20110101</span><span style="color: #080;">&#41;</span> <span style="color: #080;">+</span> years<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2012-01-01 UTC&quot;</span>
&nbsp;
leap_year<span style="color: #080;">&#40;</span><span style="color: #ff0000;">2012</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## TRUE</span>
ymd<span style="color: #080;">&#40;</span><span style="color: #ff0000;">20120101</span><span style="color: #080;">&#41;</span> <span style="color: #080;">+</span> dyears<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2012-12-31 UTC&quot;</span>
ymd<span style="color: #080;">&#40;</span><span style="color: #ff0000;">20120101</span><span style="color: #080;">&#41;</span> <span style="color: #080;">+</span> years<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## &quot;2013-01-01 UTC&quot;</span></pre></td></tr></table></div>

<p>We can use periods and durations to do basic arithmetic with date times. For example, if I wanted to set up a reoccuring weekly skype meeting with Hadley, it would occur on:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code47');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code47'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060247"><td class="code" id="p60602code47"><pre class="rsplus" style="font-family:monospace;">meetings <span style="color: #080;">&lt;-</span> meeting <span style="color: #080;">+</span> weeks<span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #080;">:</span><span style="color: #ff0000;">5</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## [1] &quot;2011-07-01 09:00:00 NZST&quot; &quot;2011-07-08 09:00:00 NZST&quot;</span>
<span style="color: #228B22;">## [3] &quot;2011-07-15 09:00:00 NZST&quot; &quot;2011-07-22 09:00:00 NZST&quot;</span>
<span style="color: #228B22;">## [5] &quot;2011-07-29 09:00:00 NZST&quot; &quot;2011-08-05 09:00:00 NZST&quot;</span></pre></td></tr></table></div>

<p>Hadley travelled to conferences at the same time as Chris. Which of these meetings would be affected? The last two.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code48');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code48'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060248"><td class="code" id="p60602code48"><pre class="rsplus" style="font-family:monospace;">meetings <span style="color: #080;">%</span>within<span style="color: #080;">%</span> jsm
<span style="color: #228B22;">## FALSE FALSE FALSE FALSE  TRUE  TRUE</span></pre></td></tr></table></div>

<p>How long was my stay in Auckland?</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code49');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code49'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060249"><td class="code" id="p60602code49"><pre class="rsplus" style="font-family:monospace;">auckland <span style="color: #080;">/</span> edays<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## 67.08333</span>
auckland <span style="color: #080;">/</span> edays<span style="color: #080;">&#40;</span><span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## 33.54167</span>
auckland <span style="color: #080;">/</span> eminutes<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## 96600</span></pre></td></tr></table></div>

<p>And so on. Alternatively, we can do modulo and integer division. Sometimes this is the more sensible than division &#8211; it is not obvious how to express a remainder as a fraction of a month because the length of a month constantly changes.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code50');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code50'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060250"><td class="code" id="p60602code50"><pre class="rsplus" style="font-family:monospace;">auckland <span style="color: #080;">%/%</span> <span style="color: #0000FF; font-weight: bold;">months</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## 2</span>
auckland <span style="color: #080;">%%</span> <span style="color: #0000FF; font-weight: bold;">months</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## 2011-08-04 12:00:00 NZST--2011-08-10 14:00:00 NZST</span></pre></td></tr></table></div>

<p>Modulo with an interval returns the remainder as a new (smaller) interval. We can turn this or any interval into a generalized time span with as.period().</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code51');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code51'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060251"><td class="code" id="p60602code51"><pre class="rsplus" style="font-family:monospace;">as.<span style="">period</span><span style="color: #080;">&#40;</span>auckland <span style="color: #080;">%%</span> <span style="color: #0000FF; font-weight: bold;">months</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## 6 days and 2 hours </span>
as.<span style="">period</span><span style="color: #080;">&#40;</span>auckland<span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## 2 months, 6 days and 2 hours</span></pre></td></tr></table></div>

<h2>Vectorization</h2>
<p>The code in lubridate is vectorized and ready to be used in both interactive settings and within functions. As an example, I offer a function for advancing a date to the last day of the month</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup><a href="javascript:;" onclick="copycode('p60602code52');">[Copy to clipboard]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p60602code52'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6060252"><td class="code" id="p60602code52"><pre class="rsplus" style="font-family:monospace;">last_day <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">date</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
    ceiling_date<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">date</span>, <span style="color: #ff0000;">&quot;month&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">-</span> days<span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
<span style="color: #228B22;"># try last_day(ymd(20000101) + months(0:11))</span></pre></td></tr></table></div>

<h2>Changes in lubridate (v 1.1.0)</h2>
<p>To comply with changes in base R, We’ve moved lubridate from an S3 class system to an S4 system. Most of these changes are contained “under the hood.” But some changes will affect how lubridate behaves and compromise previously written code. This disruption is unavoidable: previous versions of lubridate will not work on future versions of R. To see a complete list of changes, see the lubridate news file <a href="http://cran.r-project.org/web/packages/lubridate/NEWS" target="_blank">here</a>.</p>
<p>Changes between version 0.2.6 and 1.1.0 can be grouped into three main categories:</p>
<ol style="list-style-type:decimal">
<li>
<p>Subtracting two dates must now follow the default behavior of R, which is to create a difftime object. Previous versions of lubridate created an Interval object. If you receive an error involving an Interval object, please check that it is not in fact a difftime.</p>
</li>
<li>
<p>Intervals now have a direction. This means the order of the dates in new_interval(), interval() and %&#8211;% matters. You can flip the direction with int_flip and coerce all intervals to be postive with int_standardize</p>
</li>
<li>
<p>Lubridate no longer automatically coerces time span input to the correct class when performing math. This was poor programming because the user can and should explicitly control the class of their input with as.interval(), as.period(), and as.duration(). It also made lubridate needlessly chatty with messages and led to unintuitive results as we added increased functionality. When coercion is needed to perform an operation, lubridate now returns an informative error message.</p>
</li>
</ol>
<h2>Further Resources</h2>
<p>To learn more about lubridate, including the specifics of periods and durations, please read the original lubridate paper at <a href="http://www.jstatsoft.org/v40/i03/" target="_blank">http://www.jstatsoft.org/v40/<WBR>i03/</a>. Questions about lubridate can be addressed to the <a href="http://groups.google.com/group/lubridate" target="_blank">lubridate google group</a>. The development page for lubridate can be found at <a href="http://github.com/hadley/lubridate" target="_blank">http://github.com/hadley/<WBR>lubridate</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/03/do-more-with-dates-and-times-in-r-with-lubridate-1-1-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Printing nested tables in R – bridging between the {reshape} and {tables} packages</title>
		<link>http://www.r-statistics.com/2012/01/printing-nested-tables-in-r-bridging-between-the-reshape-and-tables-packages/</link>
		<comments>http://www.r-statistics.com/2012/01/printing-nested-tables-in-r-bridging-between-the-reshape-and-tables-packages/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 22:41:38 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R bloggers]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[aggregate()]]></category>
		<category><![CDATA[aggregation]]></category>
		<category><![CDATA[cast()]]></category>
		<category><![CDATA[cast_df]]></category>
		<category><![CDATA[data frame]]></category>
		<category><![CDATA[data processing]]></category>
		<category><![CDATA[LaTex]]></category>
		<category><![CDATA[melt]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[reshape]]></category>
		<category><![CDATA[reshaping]]></category>
		<category><![CDATA[Rnw]]></category>
		<category><![CDATA[sweave]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[tabular]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=921</guid>
		<description><![CDATA[This post shows how to print a prettier nested pivot table, created using the {reshape} package (similar to what you would get with Microsoft Excel), so you could print it either in the R terminal or as a LaTeX table. This task is done by bridging between the cast_df object produced by the {reshape} package, [...] <p class="read-more"><a href="http://www.r-statistics.com/2012/01/printing-nested-tables-in-r-bridging-between-the-reshape-and-tables-packages/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>This post shows how to print a <u>prettier</u> nested pivot table, created using the {reshape} package (similar to what you would get with Microsoft Excel), so you could print it either in the R terminal or as a LaTeX table.</strong>  This task is done by bridging between the cast_df object produced by the {reshape} package, and the tabular function introduced by the new {tables} package.</p>
<p>Here is an example of the type of output we wish to produce in the R terminal:</p>
<div class="wp_codebox">
<table>
<tr id="p9214">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
</pre>
</td>
<td class="code" id="p921code4">
<pre class="rsplus" style="font-family:monospace;">       ozone       solar.<span style="">r</span>        wind         temp
 month <span style="color: #0000FF; font-weight: bold;">mean</span>  <span style="color: #0000FF; font-weight: bold;">sd</span>    <span style="color: #0000FF; font-weight: bold;">mean</span>    <span style="color: #0000FF; font-weight: bold;">sd</span>     <span style="color: #0000FF; font-weight: bold;">mean</span>   <span style="color: #0000FF; font-weight: bold;">sd</span>    <span style="color: #0000FF; font-weight: bold;">mean</span>  <span style="color: #0000FF; font-weight: bold;">sd</span>
 <span style="color: #ff0000;">5</span>     <span style="color: #ff0000;">23.62</span> <span style="color: #ff0000;">22.22</span> <span style="color: #ff0000;">181.3</span>   <span style="color: #ff0000;">115.08</span> <span style="color: #ff0000;">11.623</span> <span style="color: #ff0000;">3.531</span> <span style="color: #ff0000;">65.55</span> <span style="color: #ff0000;">6.855</span>
 <span style="color: #ff0000;">6</span>     <span style="color: #ff0000;">29.44</span> <span style="color: #ff0000;">18.21</span> <span style="color: #ff0000;">190.2</span>    <span style="color: #ff0000;">92.88</span> <span style="color: #ff0000;">10.267</span> <span style="color: #ff0000;">3.769</span> <span style="color: #ff0000;">79.10</span> <span style="color: #ff0000;">6.599</span>
 <span style="color: #ff0000;">7</span>     <span style="color: #ff0000;">59.12</span> <span style="color: #ff0000;">31.64</span> <span style="color: #ff0000;">216.5</span>    <span style="color: #ff0000;">80.57</span>  <span style="color: #ff0000;">8.942</span> <span style="color: #ff0000;">3.036</span> <span style="color: #ff0000;">83.90</span> <span style="color: #ff0000;">4.316</span>
 <span style="color: #ff0000;">8</span>     <span style="color: #ff0000;">59.96</span> <span style="color: #ff0000;">39.68</span> <span style="color: #ff0000;">171.9</span>    <span style="color: #ff0000;">76.83</span>  <span style="color: #ff0000;">8.794</span> <span style="color: #ff0000;">3.226</span> <span style="color: #ff0000;">83.97</span> <span style="color: #ff0000;">6.585</span>
 <span style="color: #ff0000;">9</span>     <span style="color: #ff0000;">31.45</span> <span style="color: #ff0000;">24.14</span> <span style="color: #ff0000;">167.4</span>    <span style="color: #ff0000;">79.12</span> <span style="color: #ff0000;">10.180</span> <span style="color: #ff0000;">3.461</span> <span style="color: #ff0000;">76.90</span> <span style="color: #ff0000;">8.356</span></pre>
</td>
</tr>
</table>
</div>
<p>Or in a latex document:</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2012/01/cast_df-to-tabular.png"><img src="http://www.r-statistics.com/wp-content/uploads/2012/01/cast_df-to-tabular-300x89.png" alt="" title="cast_df to tabular" width="300" height="89" class="aligncenter size-medium wp-image-60591" /></a></p>
<h3>Motivation: creating pretty nested tables</h3>
<p>In a recent post we learned <a href="http://www.r-statistics.com/2012/01/aggregation-and-restructuring-data-from-r-in-action/">how to use the {reshape} package</a> (by <a href="http://had.co.nz/">Hadley Wickham</a>) in order to aggregate and reshape data (in R) using the melt and cast functions.</p>
<p>The cast function is wonderful but it has one problem &#8211; the format of the output.  As opposed to a pivot table in (for example) MS excel, the output of a nested table created by cast is very &#8220;flat&#8221;.  That is, there is only one row for the header, and only one column for the row names.  So for both the R terminal, or an Sweave document, when we deal with a more complex reshaping/aggregating, the result is <strong>not </strong>something you would be proud to send to a journal.</p>
<h3>The opportunity: the {tables} package</h3>
<p>The good news is that Duncan Murdoch have <a href="http://www.mail-archive.com/r-help@r-project.org/msg154819.html">recently</a> released a new package to CRAN called <a href="http://cran.r-project.org/web/packages/tables/">{tables}</a>.  The {tables} package can compute and display complex tables of summary statistics and turn them into nice looking tables in Sweave (LaTeX) documents.  For using the full power of this package, you are invited to read through its detailed (and well written) 23 pages <a href="http://cran.r-project.org/web/packages/tables/vignettes/tables.pdf">Vignette</a>.  However, some of us might have preferred to keep using the syntax of the {reshape} package, while also benefiting from the great formatting that is offered by the new {tables} package.  For this purpose, I devised a function that bridges between cast_df (from {reshape}) and the tabular function (from {tables}).</p>
<h3>The bridge: between the {tables} and the {reshape} packages</h3>
<p>The code for the function is available on my github (link: <a href="https://github.com/talgalili/R-code-snippets/blob/master/tabular.cast_df.r">tabular.cast_df.r on github</a>)  and it seems to works fine as far as I can see (though I wouldn&#8217;t run it on larger data files since it relies on melting a cast_df object.)</p>
<p>Here is an example for how to load and use the function:</p>
<div class="wp_codebox">
<table>
<tr id="p9215">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre>
</td>
<td class="code" id="p921code5">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;">######################</span>
<span style="color: #228B22;"># Loading the functions</span>
<span style="color: #228B22;">######################</span>
<span style="color: #228B22;"># Making sure we can source code from github</span>
<span style="color: #0000FF; font-weight: bold;">source</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;http://www.r-statistics.com/wp-content/uploads/2012/01/source_https.r.txt&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;"># Reading in the function for using tabular on a cast_df object:</span>
source_https<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;https://raw.github.com/talgalili/R-code-snippets/master/tabular.cast_df.r&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #228B22;">######################</span>
<span style="color: #228B22;"># example:</span>
<span style="color: #228B22;">######################</span>
&nbsp;
<span style="color: #228B22;">############</span>
<span style="color: #228B22;"># Loading and preparing some data</span>
<span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">reshape</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">names</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">airquality</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">tolower</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">names</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">airquality</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
airquality2 <span style="color: #080;">&lt;-</span> <span style="color: #CC9900; font-weight: bold;">airquality</span>
airquality2$temp2 <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">ifelse</span><span style="color: #080;">&#40;</span>airquality2$temp <span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">median</span><span style="color: #080;">&#40;</span>airquality2$temp<span style="color: #080;">&#41;</span>, <span style="color: #ff0000;">&quot;hot&quot;</span>, <span style="color: #ff0000;">&quot;cold&quot;</span><span style="color: #080;">&#41;</span>
aqm <span style="color: #080;">&lt;-</span> melt<span style="color: #080;">&#40;</span>airquality2, id<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;month&quot;</span>, <span style="color: #ff0000;">&quot;day&quot;</span>,<span style="color: #ff0000;">&quot;temp2&quot;</span><span style="color: #080;">&#41;</span>, na.<span style="">rm</span><span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">colnames</span><span style="color: #080;">&#40;</span>aqm<span style="color: #080;">&#41;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">4</span><span style="color: #080;">&#93;</span> <span style="color: #080;">&lt;-</span> <span style="color: #ff0000;">&quot;variable2&quot;</span>	<span style="color: #228B22;"># because otherwise the function is having problem when relying on the melt function of the cast object</span>
<span style="color: #0000FF; font-weight: bold;">head</span><span style="color: #080;">&#40;</span>aqm,<span style="color: #ff0000;">3</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">#  month day temp2 variable2 value</span>
<span style="color: #228B22;">#1     5   1  cold     ozone    41</span>
<span style="color: #228B22;">#2     5   2  cold     ozone    36</span>
<span style="color: #228B22;">#3     5   3  cold     ozone    12</span>
&nbsp;
<span style="color: #228B22;">############</span>
<span style="color: #228B22;"># Running the example:</span>
tabular.<span style="">cast_df</span><span style="color: #080;">&#40;</span>cast<span style="color: #080;">&#40;</span>aqm, month ~ variable2, <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">mean</span>,<span style="color: #0000FF; font-weight: bold;">sd</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
tabular<span style="color: #080;">&#40;</span>cast<span style="color: #080;">&#40;</span>aqm, month ~ variable2, <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">mean</span>,<span style="color: #0000FF; font-weight: bold;">sd</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># notice how we turned tabular to be an S3 method that can deal with a cast_df object</span>
Hmisc<span style="color: #080;">::</span><span style="">latex</span><span style="color: #080;">&#40;</span>tabular<span style="color: #080;">&#40;</span>cast<span style="color: #080;">&#40;</span>aqm, month ~ variable2, <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">mean</span>,<span style="color: #0000FF; font-weight: bold;">sd</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># this is what we would have used for an Sweave document</span></pre>
</td>
</tr>
</table>
</div>
<p>And here are the results in the terminal:</p>
<div class="wp_codebox">
<table>
<tr id="p9216">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre>
</td>
<td class="code" id="p921code6">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span>
<span style="color: #080;">&gt;</span> tabular.<span style="">cast_df</span><span style="color: #080;">&#40;</span>cast<span style="color: #080;">&#40;</span>aqm, month ~ variable2, <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">mean</span>,<span style="color: #0000FF; font-weight: bold;">sd</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
       ozone       solar.<span style="">r</span>        wind         temp
 month <span style="color: #0000FF; font-weight: bold;">mean</span>  <span style="color: #0000FF; font-weight: bold;">sd</span>    <span style="color: #0000FF; font-weight: bold;">mean</span>    <span style="color: #0000FF; font-weight: bold;">sd</span>     <span style="color: #0000FF; font-weight: bold;">mean</span>   <span style="color: #0000FF; font-weight: bold;">sd</span>    <span style="color: #0000FF; font-weight: bold;">mean</span>  <span style="color: #0000FF; font-weight: bold;">sd</span>
 <span style="color: #ff0000;">5</span>     <span style="color: #ff0000;">23.62</span> <span style="color: #ff0000;">22.22</span> <span style="color: #ff0000;">181.3</span>   <span style="color: #ff0000;">115.08</span> <span style="color: #ff0000;">11.623</span> <span style="color: #ff0000;">3.531</span> <span style="color: #ff0000;">65.55</span> <span style="color: #ff0000;">6.855</span>
 <span style="color: #ff0000;">6</span>     <span style="color: #ff0000;">29.44</span> <span style="color: #ff0000;">18.21</span> <span style="color: #ff0000;">190.2</span>    <span style="color: #ff0000;">92.88</span> <span style="color: #ff0000;">10.267</span> <span style="color: #ff0000;">3.769</span> <span style="color: #ff0000;">79.10</span> <span style="color: #ff0000;">6.599</span>
 <span style="color: #ff0000;">7</span>     <span style="color: #ff0000;">59.12</span> <span style="color: #ff0000;">31.64</span> <span style="color: #ff0000;">216.5</span>    <span style="color: #ff0000;">80.57</span>  <span style="color: #ff0000;">8.942</span> <span style="color: #ff0000;">3.036</span> <span style="color: #ff0000;">83.90</span> <span style="color: #ff0000;">4.316</span>
 <span style="color: #ff0000;">8</span>     <span style="color: #ff0000;">59.96</span> <span style="color: #ff0000;">39.68</span> <span style="color: #ff0000;">171.9</span>    <span style="color: #ff0000;">76.83</span>  <span style="color: #ff0000;">8.794</span> <span style="color: #ff0000;">3.226</span> <span style="color: #ff0000;">83.97</span> <span style="color: #ff0000;">6.585</span>
 <span style="color: #ff0000;">9</span>     <span style="color: #ff0000;">31.45</span> <span style="color: #ff0000;">24.14</span> <span style="color: #ff0000;">167.4</span>    <span style="color: #ff0000;">79.12</span> <span style="color: #ff0000;">10.180</span> <span style="color: #ff0000;">3.461</span> <span style="color: #ff0000;">76.90</span> <span style="color: #ff0000;">8.356</span>
<span style="color: #080;">&gt;</span> tabular<span style="color: #080;">&#40;</span>cast<span style="color: #080;">&#40;</span>aqm, month ~ variable2, <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">mean</span>,<span style="color: #0000FF; font-weight: bold;">sd</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># notice how we turned tabular to be an S3 method that can deal with a cast_df object</span>
&nbsp;
       ozone       solar.<span style="">r</span>        wind         temp
 month <span style="color: #0000FF; font-weight: bold;">mean</span>  <span style="color: #0000FF; font-weight: bold;">sd</span>    <span style="color: #0000FF; font-weight: bold;">mean</span>    <span style="color: #0000FF; font-weight: bold;">sd</span>     <span style="color: #0000FF; font-weight: bold;">mean</span>   <span style="color: #0000FF; font-weight: bold;">sd</span>    <span style="color: #0000FF; font-weight: bold;">mean</span>  <span style="color: #0000FF; font-weight: bold;">sd</span>
 <span style="color: #ff0000;">5</span>     <span style="color: #ff0000;">23.62</span> <span style="color: #ff0000;">22.22</span> <span style="color: #ff0000;">181.3</span>   <span style="color: #ff0000;">115.08</span> <span style="color: #ff0000;">11.623</span> <span style="color: #ff0000;">3.531</span> <span style="color: #ff0000;">65.55</span> <span style="color: #ff0000;">6.855</span>
 <span style="color: #ff0000;">6</span>     <span style="color: #ff0000;">29.44</span> <span style="color: #ff0000;">18.21</span> <span style="color: #ff0000;">190.2</span>    <span style="color: #ff0000;">92.88</span> <span style="color: #ff0000;">10.267</span> <span style="color: #ff0000;">3.769</span> <span style="color: #ff0000;">79.10</span> <span style="color: #ff0000;">6.599</span>
 <span style="color: #ff0000;">7</span>     <span style="color: #ff0000;">59.12</span> <span style="color: #ff0000;">31.64</span> <span style="color: #ff0000;">216.5</span>    <span style="color: #ff0000;">80.57</span>  <span style="color: #ff0000;">8.942</span> <span style="color: #ff0000;">3.036</span> <span style="color: #ff0000;">83.90</span> <span style="color: #ff0000;">4.316</span>
 <span style="color: #ff0000;">8</span>     <span style="color: #ff0000;">59.96</span> <span style="color: #ff0000;">39.68</span> <span style="color: #ff0000;">171.9</span>    <span style="color: #ff0000;">76.83</span>  <span style="color: #ff0000;">8.794</span> <span style="color: #ff0000;">3.226</span> <span style="color: #ff0000;">83.97</span> <span style="color: #ff0000;">6.585</span>
 <span style="color: #ff0000;">9</span>     <span style="color: #ff0000;">31.45</span> <span style="color: #ff0000;">24.14</span> <span style="color: #ff0000;">167.4</span>    <span style="color: #ff0000;">79.12</span> <span style="color: #ff0000;">10.180</span> <span style="color: #ff0000;">3.461</span> <span style="color: #ff0000;">76.90</span> <span style="color: #ff0000;">8.356</span></pre>
</td>
</tr>
</table>
</div>
<p>And in an Sweave document:</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2012/01/cast_df-to-tabular.png"><img src="http://www.r-statistics.com/wp-content/uploads/2012/01/cast_df-to-tabular-300x89.png" alt="" title="cast_df to tabular" width="300" height="89" class="aligncenter size-medium wp-image-60591" /></a></p>
<p>Here is an example for the Rnw file that produces the above table:<br />
<a href='http://www.r-statistics.com/wp-content/uploads/2012/01/cast_df-to-tabular.Rnw_.txt'>cast_df to tabular.Rnw</a></p>
<p>I will finish with saying that the tabular function offers more flexibility then the one offered by the function I provided.  If you find any bugs or have suggestions of improvement, you are invited to leave a comment here or <a href="https://github.com/talgalili/R-code-snippets/blob/master/tabular.cast_df.r">inside the code on github</a>.</p>
<p>(Link-tip goes to <a href="http://tonybreyal.wordpress.com/">Tony Breyal</a> for putting together <a href="http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/">a solution</a> for sourcing r code from github.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/01/printing-nested-tables-in-r-bridging-between-the-reshape-and-tables-packages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interactive Graphics with the iplots Package (from “R in Action”)</title>
		<link>http://www.r-statistics.com/2012/01/interactive-graphics-with-the-iplots-package-from-r-in-action/</link>
		<comments>http://www.r-statistics.com/2012/01/interactive-graphics-with-the-iplots-package-from-r-in-action/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 12:29:38 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R bloggers]]></category>
		<category><![CDATA[visualization]]></category>
		<category><![CDATA[ihist]]></category>
		<category><![CDATA[interaction visualization]]></category>
		<category><![CDATA[iplot]]></category>
		<category><![CDATA[iplots]]></category>
		<category><![CDATA[manning]]></category>
		<category><![CDATA[R in action]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=913</guid>
		<description><![CDATA[The followings introductory post is intended for new users of R.  It deals with interactive visualization using R through the iplots package. This is a guest article by Dr. Robert I. Kabacoff, the founder of (one of) the first online R &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2012/01/interactive-graphics-with-the-iplots-package-from-r-in-action/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>The followings introductory post is intended for new users of R.  It deals with interactive visualization using R through the iplots package.</strong></p>
<p>This is a guest article by Dr. <a href="http://www.statmethods.net/about/author.html">Robert I. Kabacoff</a>, the founder of (one of) the first online R tutorials websites: <a href="http://www.statmethods.net/interface/index.html">Quick-R</a>. Kabacoff has recently published the book &#8221;<strong><a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=21">R in Action</a></strong>&#8220;, providing a detailed walk-through for the R language based on various examples for illustrating R’s features (data manipulation, statistical methods, graphics, and so on&#8230;). In <a href="http://www.r-statistics.com/2011/12/data-frame-objects-in-r-via-r-in-action/">previous guest post</a>s by Kabacoff we introduced <a href="http://www.r-statistics.com/2011/12/data-frame-objects-in-r-via-r-in-action/">data.frame objects in R</a> and dealt with the <a href="http://www.r-statistics.com/2012/01/aggregation-and-restructuring-data-from-r-in-action/">Aggregation and Restructuring of data</a> (using base R functions and the reshape package).</p>
<p>For readers of this blog, there is a<strong> 38% discount</strong> off <a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=21">the &#8220;R in Action&#8221; book</a> (as well as all other eBooks, pBooks and MEAPs at <a href="http://affiliate.manning.com/idevaffiliate.php?id=1205">Manning publishing house</a>), simply by using the code <em><strong>rblogg38 </strong></em>when reaching checkout.</p>
<p>Let us now talk about Interactive Graphics with the iplots Package:<br />
<img title="More..." src="http://www.r-statistics.com/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif" alt="" /></p>
<p><span id="more-913"></span></p>
<h3><span style="text-decoration: underline;">Interactive Graphics with the iplots Package<br />
</span></h3>
<p>The base installation of R provides limited interactivity with graphs. You can modify graphs by issuing additional program statements, but there’s little that you can do to modify them or gather new information from them using the mouse. However, there are contributed packages that greatly enhance your ability to interact with the graphs you create—playwith, latticist, iplots, and rggobi. In this article, we’ll focus on functions provided by the iplots package. Be sure to install it before first use.</p>
<p>While playwith and latticist allow you to interact with a single graph, the iplots package takes interaction in a different direction. This package provides interactive mosaic plots, bar plots, box plots, parallel plots, scatter plots, and histograms that can be linked together and color brushed. This means that you can select and identify observations using the mouse, and highlighting observations in one graph will automatically highlight the same observations in all other open graphs. You can also use the mouse to obtain information about graphic objects such as points, bars, lines, and box plots.</p>
<p>The iplots package is implemented through Java and the primary functions are listed in table 1.</p>
<p><em>Table 1 <strong>iplot </strong>functions</em></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="73">
<div>
<p>Function</p>
</div>
</td>
<td valign="top" width="186">
<div>
<p>Description</p>
</div>
</td>
</tr>
<tr>
<td valign="bottom" width="73">ibar()</td>
<td valign="bottom" width="186">Interactive bar chart</td>
</tr>
<tr>
<td valign="bottom" width="73">ibox()</td>
<td valign="bottom" width="186">Interactive box plot</td>
</tr>
<tr>
<td valign="bottom" width="73">ihist()</td>
<td valign="bottom" width="186">Interactive histogram</td>
</tr>
<tr>
<td valign="bottom" width="73">imap()</td>
<td valign="bottom" width="186">Interactive map</td>
</tr>
<tr>
<td valign="bottom" width="73">imosaic()</td>
<td valign="bottom" width="186">Interactive mosaic plot</td>
</tr>
<tr>
<td valign="bottom" width="73">ipcp()</td>
<td valign="bottom" width="186">Interactive parallel coordinates plot</td>
</tr>
<tr>
<td valign="bottom" width="73">iplot()</td>
<td valign="bottom" width="186">Interactive scatter plot</td>
</tr>
</tbody>
</table>
<p>To understand how iplots works, execute the code provided in listing 1.</p>
<p><em>Listing 1 iplots demonstration<br />
</em></p>
<div class="wp_codebox">
<table>
<tr id="p9132">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre>
</td>
<td class="code" id="p913code2">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">library</span><span style="color: #080;">&#40;</span>iplots<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">attach</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span><span style="color: #080;">&#41;</span>
cylinders <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">factor</span><span style="color: #080;">&#40;</span>cyl<span style="color: #080;">&#41;</span>
gears <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">factor</span><span style="color: #080;">&#40;</span>gear<span style="color: #080;">&#41;</span>
transmission <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">factor</span><span style="color: #080;">&#40;</span>am<span style="color: #080;">&#41;</span>
ihist<span style="color: #080;">&#40;</span>mpg<span style="color: #080;">&#41;</span>
ibar<span style="color: #080;">&#40;</span>gears<span style="color: #080;">&#41;</span>
iplot<span style="color: #080;">&#40;</span>mpg, wt<span style="color: #080;">&#41;</span>
ibox<span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span><span style="color: #080;">&#91;</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;mpg&quot;</span>, <span style="color: #ff0000;">&quot;wt&quot;</span>, <span style="color: #ff0000;">&quot;qsec&quot;</span>, <span style="color: #ff0000;">&quot;disp&quot;</span>, <span style="color: #ff0000;">&quot;hp&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
ipcp<span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span><span style="color: #080;">&#91;</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;mpg&quot;</span>, <span style="color: #ff0000;">&quot;wt&quot;</span>, <span style="color: #ff0000;">&quot;qsec&quot;</span>, <span style="color: #ff0000;">&quot;disp&quot;</span>, <span style="color: #ff0000;">&quot;hp&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
imosaic<span style="color: #080;">&#40;</span>transmission, cylinders<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">detach</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span><span style="color: #080;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>Six windows containing graphs will open. Rearrange them on the desktop so that each is visible (each can be resized if necessary). A portion of the display is provided in figure 1.</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2012/01/iplots-example.png"><img src="http://www.r-statistics.com/wp-content/uploads/2012/01/iplots-example-300x289.png" alt="" title="iplots-example" width="300" height="289" class="aligncenter size-medium wp-image-60660" /></a></p>
<p><em>Figure 1 An <strong>iplots </strong>demonstration created by listing 1. Only four of the six windows are displayed to save room. In these graphs, the user has clicked on the three-gear bar in the bar chart window.</em></p>
<p>Now try the following:</p>
<ul>
<li>Click on the three-gear bar in the Barchart (gears) window. The bar will turn red. In addition, all cars with three-gear engines will be highlighted in the other graph windows.</li>
<li>Mouse down and drag to select a rectangular region of points in the Scatter plot (wt vs mpg) window. These points will be highlighted and the corresponding observations in every other graph window will also turn red.</li>
<li>Hold down the Ctrl key and move the mouse pointer over a point, bar, box plot, or line in one of the graphs. Details about that object will appear in a pop-up window.</li>
<li>Right-click on any object and note the options that are offered in the context menu. For example, you can right-click on the Boxplot (mpg) window and change the graph to a parallel coordinates plot (PCP).</li>
<li>You can drag to select more than one object (point, bar, and so on) or use Shift-click to select noncontiguous objects. Try selecting both the three- and five-gear bars in the Barchart (gears) window.</li>
</ul>
<p>The functions in the iplots package allow you to explore the variable distributions and relationships among variables in subgroups of observations that you select interactively. This can provide insights that would be difficult and time-consuming to obtain in other ways. For more information on the iplots package, visit the project website at <a href="http://rosuda.org/iplots/">http://rosuda.org/iplots/</a>.</p>
<h3>Summary</h3>
<p>In this article, we explored one of the several packages for dynamically interacting with graphs, iplots. This package allows you to interact directly with data in graphs, leading to a greater intimacy with your data and expanded opportunities for developing insights.</p>
<p><span style="text-decoration: underline;"><br />
</span></p>
<p><em>This article first appeared as chapter 16.4.4 from the &#8220;<a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=21">R in action</a><strong>&#8220;</strong> book, and is published with permission from <a href="http://affiliate.manning.com/idevaffiliate.php?id=1205">Manning publishing house</a>.  Other books in this serious which you might be interested in are (see the beginning of this post for a discount code):</em></p>
<ul>
<li><a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=22">Machine Learning in Action </a>by Peter Harrington</li>
</ul>
<ul>
<li><a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=23">Gnuplot in Action</a> (Understanding Data with Graphs) by Philipp K. Janert</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/01/interactive-graphics-with-the-iplots-package-from-r-in-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merging two data.frame objects while preserving the rows’ order</title>
		<link>http://www.r-statistics.com/2012/01/merging-two-data-frame-objects-while-preserving-the-rows-order/</link>
		<comments>http://www.r-statistics.com/2012/01/merging-two-data-frame-objects-while-preserving-the-rows-order/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 11:17:01 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R bloggers]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[data frame]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[merging]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[sorting]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=903</guid>
		<description><![CDATA[Merging two data.frame objects in R is very easily done by using the merge function. While being very powerful, the merge function does not (as of yet) offer to return a merged data.frame that preserved the original order of, one of the two merged, data.frame objects. In this post I describe this problem, and offer [...] <p class="read-more"><a href="http://www.r-statistics.com/2012/01/merging-two-data-frame-objects-while-preserving-the-rows-order/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Merging two data.frame objects in R is very easily done by using the merge function.  While being very powerful, the merge function does not (as of yet) offer to return a merged data.frame that preserved the original order of, one of the two merged, data.frame objects.<br />
In this post I describe this problem, and offer some easy to use code to solve it.<br />
<span id="more-903"></span></p>
<p>Let us start with a simple example:</p>
<div class="wp_codebox">
<table>
<tr id="p90312">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre>
</td>
<td class="code" id="p903code12">
<pre class="rsplus" style="font-family:monospace;">    x <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span><span style="color: #080;">&#40;</span>
           ref <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span> <span style="color: #ff0000;">'Ref1'</span>, <span style="color: #ff0000;">'Ref2'</span> <span style="color: #080;">&#41;</span>
         , label <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span> <span style="color: #ff0000;">'Label01'</span>, <span style="color: #ff0000;">'Label02'</span> <span style="color: #080;">&#41;</span>
         <span style="color: #080;">&#41;</span>
    y <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span><span style="color: #080;">&#40;</span>
          id <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span> <span style="color: #ff0000;">'A1'</span>, <span style="color: #ff0000;">'C2'</span>, <span style="color: #ff0000;">'B3'</span>, <span style="color: #ff0000;">'D4'</span> <span style="color: #080;">&#41;</span>
        , ref <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span> <span style="color: #ff0000;">'Ref1'</span>, <span style="color: #ff0000;">'Ref2'</span> , <span style="color: #ff0000;">'Ref3'</span>,<span style="color: #ff0000;">'Ref1'</span> <span style="color: #080;">&#41;</span>
        , val <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span> <span style="color: #ff0000;">1.11</span>, <span style="color: #ff0000;">2.22</span>, <span style="color: #ff0000;">3.33</span>, <span style="color: #ff0000;">4.44</span> <span style="color: #080;">&#41;</span>
        <span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;">#######################</span>
<span style="color: #228B22;"># having a look at the two data.frame objects:</span>
<span style="color: #080;">&gt;</span> x
   ref   label
<span style="color: #ff0000;">1</span> Ref1 Label01
<span style="color: #ff0000;">2</span> Ref2 Label02
<span style="color: #080;">&gt;</span> y
  id  ref  val
<span style="color: #ff0000;">1</span> A1 Ref1 <span style="color: #ff0000;">1.11</span>
<span style="color: #ff0000;">2</span> C2 Ref2 <span style="color: #ff0000;">2.22</span>
<span style="color: #ff0000;">3</span> B3 Ref3 <span style="color: #ff0000;">3.33</span>
<span style="color: #ff0000;">4</span> D4 Ref1 <span style="color: #ff0000;">4.44</span></pre>
</td>
</tr>
</table>
</div>
<p>If we will now merge the two objects, we will find that the order of the rows is different then the original order of the &#8220;y&#8221; object.  This is true whether we use &#8220;sort =T&#8221; or &#8220;sort=F&#8221;.  You can notice that the original order was an ascending order of the &#8220;val&#8221; variable:</p>
<div class="wp_codebox">
<table>
<tr id="p90313">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre>
</td>
<td class="code" id="p903code13">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">merge</span><span style="color: #080;">&#40;</span> x, y, <span style="color: #0000FF; font-weight: bold;">by</span><span style="color: #080;">=</span><span style="color: #ff0000;">'ref'</span>, all.<span style="">y</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">sort</span><span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">T</span><span style="color: #080;">&#41;</span>
   ref   label id  val
<span style="color: #ff0000;">1</span> Ref1 Label01 A1 <span style="color: #ff0000;">1.11</span>
<span style="color: #ff0000;">2</span> Ref1 Label01 D4 <span style="color: #ff0000;">4.44</span>
<span style="color: #ff0000;">3</span> Ref2 Label02 C2 <span style="color: #ff0000;">2.22</span>
<span style="color: #ff0000;">4</span> Ref3    <span style="color: #080;">&lt;</span>NA<span style="color: #080;">&gt;</span> B3 <span style="color: #ff0000;">3.33</span>
<span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">merge</span><span style="color: #080;">&#40;</span> x, y, <span style="color: #0000FF; font-weight: bold;">by</span><span style="color: #080;">=</span><span style="color: #ff0000;">'ref'</span>, all.<span style="">y</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">sort</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">F</span> <span style="color: #080;">&#41;</span>
   ref   label id  val
<span style="color: #ff0000;">1</span> Ref1 Label01 A1 <span style="color: #ff0000;">1.11</span>
<span style="color: #ff0000;">2</span> Ref1 Label01 D4 <span style="color: #ff0000;">4.44</span>
<span style="color: #ff0000;">3</span> Ref2 Label02 C2 <span style="color: #ff0000;">2.22</span>
<span style="color: #ff0000;">4</span> Ref3    <span style="color: #080;">&lt;</span>NA<span style="color: #080;">&gt;</span> B3 <span style="color: #ff0000;">3.33</span></pre>
</td>
</tr>
</table>
</div>
<p>This is explained in the help page of ?merge:</p>
<blockquote><p>The rows are by default lexicographically sorted on the common columns, but for ‘sort = FALSE’ are in an unspecified order.
</p>
</blockquote>
<p>Or put differently: sort=FALSE doesn&#8217;t preserve the order of any of the two entered data.frame objects (x or y); instead it gives us an<br />
unspecified (potentially random) order.</p>
<p>However, it can so happen that we want to make sure the order of the resulting merged data.frame objects ARE ordered according to the order of one of the two original objects.  In order to make sure of that, we could add an extra &#8220;id&#8221; (row index number) sequence on the dataframe we wish to sort on.  Then, we can merge the two data.frame objects, sort by the sequence, and delete the sequence. (this was previously mentioned on the R-help mailing list by <a href="http://www.mail-archive.com/r-help@r-project.org/msg83160.html">Bart Joosen</a>).</p>
<p>Following is a function that implements this logic, followed by an example for its use:</p>
<div class="wp_codebox">
<table>
<tr id="p90314">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre>
</td>
<td class="code" id="p903code14">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;">############## function:</span>
	merge.<span style="">with</span>.<span style="">order</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>x,y, ..., <span style="color: #0000FF; font-weight: bold;">sort</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">T</span>, keep_order<span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#123;</span>
		<span style="color: #228B22;"># this function works just like merge, only that it adds the option to return the merged data.frame ordered by x (1) or by y (2)</span>
		add.<span style="">id</span>.<span style="">column</span>.<span style="">to</span>.<span style="">data</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>DATA<span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#123;</span>
			<span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span><span style="color: #080;">&#40;</span>DATA, id... <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">seq_len</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">nrow</span><span style="color: #080;">&#40;</span>DATA<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span>
		<span style="color: #228B22;"># add.id.column.to.data(data.frame(x = rnorm(5), x2 = rnorm(5)))</span>
		order.<span style="">by</span>.<span style="">id</span>...<span style="">and</span>.<span style="">remove</span>.<span style="">it</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>DATA<span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#123;</span>
			<span style="color: #228B22;"># gets in a data.frame with the &quot;id...&quot; column.  Orders by it and returns it</span>
			<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">any</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">colnames</span><span style="color: #080;">&#40;</span>DATA<span style="color: #080;">&#41;</span><span style="color: #080;">==</span><span style="color: #ff0000;">&quot;id...&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF; font-weight: bold;">stop</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;The function order.by.id...and.remove.it only works with data.frame objects which includes the 'id...' order column&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
			ss_r <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">order</span><span style="color: #080;">&#40;</span>DATA$id...<span style="color: #080;">&#41;</span>
			ss_c <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">colnames</span><span style="color: #080;">&#40;</span>DATA<span style="color: #080;">&#41;</span> <span style="color: #080;">!=</span> <span style="color: #ff0000;">&quot;id...&quot;</span>
			DATA<span style="color: #080;">&#91;</span>ss_r, ss_c<span style="color: #080;">&#93;</span>
		<span style="color: #080;">&#125;</span>
&nbsp;
		<span style="color: #228B22;"># tmp &lt;- function(x) x==1; 1	# why we must check what to do if it is missing or not...</span>
		<span style="color: #228B22;"># tmp()</span>
&nbsp;
		<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">missing</span><span style="color: #080;">&#40;</span>keep_order<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#123;</span>
			<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span>keep_order <span style="color: #080;">==</span> <span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF; font-weight: bold;">return</span><span style="color: #080;">&#40;</span>order.<span style="">by</span>.<span style="">id</span>...<span style="">and</span>.<span style="">remove</span>.<span style="">it</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">merge</span><span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>add.<span style="">id</span>.<span style="">column</span>.<span style="">to</span>.<span style="">data</span><span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span>,y<span style="color: #080;">=</span>y,..., <span style="color: #0000FF; font-weight: bold;">sort</span> <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
			<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span>keep_order <span style="color: #080;">==</span> <span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span> <span style="color: #0000FF; font-weight: bold;">return</span><span style="color: #080;">&#40;</span>order.<span style="">by</span>.<span style="">id</span>...<span style="">and</span>.<span style="">remove</span>.<span style="">it</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">merge</span><span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>x,y<span style="color: #080;">=</span>add.<span style="">id</span>.<span style="">column</span>.<span style="">to</span>.<span style="">data</span><span style="color: #080;">&#40;</span>y<span style="color: #080;">&#41;</span>,..., <span style="color: #0000FF; font-weight: bold;">sort</span> <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
			<span style="color: #228B22;"># if you didn't get &quot;return&quot; by now - issue a warning.</span>
			<span style="color: #0000FF; font-weight: bold;">warning</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;The function merge.with.order only accepts NULL/1/2 values for the keep_order variable&quot;</span><span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span> <span style="color: #0000FF; font-weight: bold;">else</span> <span style="color: #080;">&#123;</span><span style="color: #0000FF; font-weight: bold;">return</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">merge</span><span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>x,y<span style="color: #080;">=</span>y,..., <span style="color: #0000FF; font-weight: bold;">sort</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">sort</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;">######### example:</span>
<span style="color: #080;">&gt;</span>     <span style="color: #0000FF; font-weight: bold;">merge</span><span style="color: #080;">&#40;</span> x.<span style="">labels</span>, x.<span style="">vals</span>, <span style="color: #0000FF; font-weight: bold;">by</span><span style="color: #080;">=</span><span style="color: #ff0000;">'ref'</span>, all.<span style="">y</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">sort</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">F</span> <span style="color: #080;">&#41;</span>
   ref   label id  val
<span style="color: #ff0000;">1</span> Ref1 Label01 A1 <span style="color: #ff0000;">1.11</span>
<span style="color: #ff0000;">2</span> Ref1 Label01 D4 <span style="color: #ff0000;">4.44</span>
<span style="color: #ff0000;">3</span> Ref2 Label02 C2 <span style="color: #ff0000;">2.22</span>
<span style="color: #ff0000;">4</span> Ref3    <span style="color: #080;">&lt;</span>NA<span style="color: #080;">&gt;</span> B3 <span style="color: #ff0000;">3.33</span>
<span style="color: #080;">&gt;</span>     merge.<span style="">with</span>.<span style="">order</span><span style="color: #080;">&#40;</span> x.<span style="">labels</span>, x.<span style="">vals</span>, <span style="color: #0000FF; font-weight: bold;">by</span><span style="color: #080;">=</span><span style="color: #ff0000;">'ref'</span>, all.<span style="">y</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">sort</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">F</span> ,keep_order <span style="color: #080;">=</span> <span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
   ref   label id  val
<span style="color: #ff0000;">1</span> Ref1 Label01 A1 <span style="color: #ff0000;">1.11</span>
<span style="color: #ff0000;">2</span> Ref1 Label01 D4 <span style="color: #ff0000;">4.44</span>
<span style="color: #ff0000;">3</span> Ref2 Label02 C2 <span style="color: #ff0000;">2.22</span>
<span style="color: #ff0000;">4</span> Ref3    <span style="color: #080;">&lt;</span>NA<span style="color: #080;">&gt;</span> B3 <span style="color: #ff0000;">3.33</span>
<span style="color: #080;">&gt;</span>     merge.<span style="">with</span>.<span style="">order</span><span style="color: #080;">&#40;</span> x.<span style="">labels</span>, x.<span style="">vals</span>, <span style="color: #0000FF; font-weight: bold;">by</span><span style="color: #080;">=</span><span style="color: #ff0000;">'ref'</span>, all.<span style="">y</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">sort</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">F</span> ,keep_order <span style="color: #080;">=</span> <span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># yay - works as we wanted it to...</span>
   ref   label id  val
<span style="color: #ff0000;">1</span> Ref1 Label01 A1 <span style="color: #ff0000;">1.11</span>
<span style="color: #ff0000;">3</span> Ref2 Label02 C2 <span style="color: #ff0000;">2.22</span>
<span style="color: #ff0000;">4</span> Ref3    <span style="color: #080;">&lt;</span>NA<span style="color: #080;">&gt;</span> B3 <span style="color: #ff0000;">3.33</span>
<span style="color: #ff0000;">2</span> Ref1 Label01 D4 <span style="color: #ff0000;">4.44</span></pre>
</td>
</tr>
</table>
</div>
<p>Here is a description for how to use the keep_order parameter:</p>
<blockquote><p>keep_order can accept the numbers 1 or 2, in which case it will make sure the resulting merged data.frame will be ordered according to the original order of rows of the data.frame entered to x (if keep_order=1) or to y (if keep_order=2).  If keep_order is missing, merge will continue working as usual.  If keep_order gets some input other then 1 or 2, it will issue a warning that it doesn&#8217;t accept these values, but will continue working as merge normally would.  Notice that the parameter &#8220;sort&#8221; is practically overridden when using keep_order (with the value 1 or 2).
</p>
</blockquote>
<p>The same code can be used to modify the original merge.data.frame function in base R, so to allow the use of the keep_order, here is <a href="https://github.com/talgalili/R-code-snippets/blob/master/merge.data.frame.r">a link to the patched merge.data.frame function (on github).</a> If you can think of any ways to improve the function (or happen to notice a bug) please let me know either on github or in the comments.  (also saying that you found the function to be useful will be fun to know about <img src='http://www.r-statistics.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
<p><u><strong>Update</strong></u>: Thanks to KY&#8217;s comment, I noticed the ?join function in the {plyr} library.  This function is similar to merge (with less features, yet faster), and also automatically keeps the order of the x (first) data.frame used for merging, as explained in the ?join help page:</p>
<blockquote><p>Unlike merge, (join) preserves the order of x no matter what join type is used. If needed, rows from y will be added to the bottom. Join is often faster than merge, although it is somewhat less featureful &#8211; it currently offers no way to rename output or merge on different variables in the x and y data frames.
</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/01/merging-two-data-frame-objects-while-preserving-the-rows-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aggregation and Restructuring data (from “R in Action”)</title>
		<link>http://www.r-statistics.com/2012/01/aggregation-and-restructuring-data-from-r-in-action/</link>
		<comments>http://www.r-statistics.com/2012/01/aggregation-and-restructuring-data-from-r-in-action/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 05:29:54 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R bloggers]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[aggregate()]]></category>
		<category><![CDATA[data frame]]></category>
		<category><![CDATA[hadely]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[reshape]]></category>
		<category><![CDATA[transpose]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=891</guid>
		<description><![CDATA[The followings introductory post is intended for new users of R.  It deals with the restructuring of data: what it is and how to perform it using base R functions and the {reshape} package. This is a guest article by Dr. Robert I. Kabacoff, the founder of (one of) the first online R tutorials websites: Quick-R. Kabacoff [...] <p class="read-more"><a href="http://www.r-statistics.com/2012/01/aggregation-and-restructuring-data-from-r-in-action/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>The followings introductory post is intended for new users of R.  It deals with the restructuring of data: what it is and how to perform it using base R functions and the {reshape} package.</strong></p>
<p>This is a guest article by Dr. <a href="http://www.statmethods.net/about/author.html">Robert I. Kabacoff</a>, the founder of (one of) the first online R tutorials websites: <a href="http://www.statmethods.net/interface/index.html">Quick-R</a>.   Kabacoff has recently published the book &#8221;<strong><a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=21">R in Action</a></strong>&#8220;, providing a detailed walk-through for the R language based on various examples for illustrating R’s features (data manipulation, statistical methods, graphics, and so on&#8230;).  The <a href="http://www.r-statistics.com/2011/12/data-frame-objects-in-r-via-r-in-action/">previous guest post</a> by Kabacoff introduced <a href="http://www.r-statistics.com/2011/12/data-frame-objects-in-r-via-r-in-action/">data.frame objects in R</a>.</p>
<p><a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=21"><img class="alignright" title="R in Action cover image" src="http://www.r-statistics.com/wp-content/uploads/2011/12/kabacoff_cover150.jpg" alt="" width="150" height="188" /></a>For readers of this blog, there is a<strong> 38% discount</strong> off <a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=21">the &#8220;R in Action&#8221; book</a> (as well as all other eBooks, pBooks and MEAPs at <a href="http://affiliate.manning.com/idevaffiliate.php?id=1205">Manning publishing house</a>), simply by using the code <em><strong>rblogg38 </strong></em>when reaching checkout.</p>
<p>Let us now talk about the Aggregation and Restructuring of data in R:<br />
<img title="More..." src="http://www.r-statistics.com/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif" alt="" /></p>
<p><span id="more-891"></span></p>
<h3><span style="text-decoration: underline;">Aggregation and Restructuring</span></h3>
<p>R provides a number of powerful methods for aggregating and reshaping data. When you aggregate data, you replace groups of observations with summary statistics based on those observations. When you reshape data, you alter the structure (rows and columns) determining how the data is organized. This article describes a variety of methods for accomplishing these tasks.</p>
<p>We’ll use the mtcars data frame that’s included with the base installation of R. This dataset, extracted from Motor Trend magazine (1974), describes the design and performance characteristics (number of cylinders, displacement, horsepower, mpg, and so on) for 34 automobiles. To learn more about the dataset, see help(mtcars).</p>
<h3><span style="text-decoration: underline;">Transpose</span></h3>
<p>The transpose (reversing rows and columns) is perhaps the simplest method of reshaping a dataset. Use the t() function to transpose a matrix or a data frame. In the latter case, row names become variable (column) names. An example is presented in the next listing.</p>
<p><em><strong>Listing 1 Transposing a dataset</strong></em></p>
<div class="wp_codebox">
<table>
<tr id="p89121">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre>
</td>
<td class="code" id="p891code21">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> <span style="color: #CC9900; font-weight: bold;">cars</span> <span style="color: #080;">&lt;-</span> <span style="color: #CC9900; font-weight: bold;">mtcars</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">5</span>,<span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">4</span><span style="color: #080;">&#93;</span>
<span style="color: #080;">&gt;</span> <span style="color: #CC9900; font-weight: bold;">cars</span>
                  mpg  cyl disp  hp
Mazda RX4         <span style="color: #ff0000;">21.0</span>   <span style="color: #ff0000;">6</span>  <span style="color: #ff0000;">160</span> <span style="color: #ff0000;">110</span>
Mazda RX4 Wag     <span style="color: #ff0000;">21.0</span>   <span style="color: #ff0000;">6</span>  <span style="color: #ff0000;">160</span> <span style="color: #ff0000;">110</span>
Datsun <span style="color: #ff0000;">710</span>        <span style="color: #ff0000;">22.8</span>   <span style="color: #ff0000;">4</span>  <span style="color: #ff0000;">108</span> <span style="color: #ff0000;">93</span>
Hornet <span style="color: #ff0000;">4</span> Drive    <span style="color: #ff0000;">21.4</span>   <span style="color: #ff0000;">6</span>  <span style="color: #ff0000;">258</span> <span style="color: #ff0000;">110</span>
Hornet Sportabout <span style="color: #ff0000;">18.7</span>   <span style="color: #ff0000;">8</span>  <span style="color: #ff0000;">360</span> <span style="color: #ff0000;">175</span>
<span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">t</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">cars</span><span style="color: #080;">&#41;</span>
     Mazda RX4 Mazda RX4 Wag Datsun <span style="color: #ff0000;">710</span> Hornet <span style="color: #ff0000;">4</span> Drive Hornet Sportabout
mpg         <span style="color: #ff0000;">21</span>        <span style="color: #ff0000;">21</span>           <span style="color: #ff0000;">22.8</span>           <span style="color: #ff0000;">21.4</span>              <span style="color: #ff0000;">18.7</span>
cyl          <span style="color: #ff0000;">6</span>         <span style="color: #ff0000;">6</span>            <span style="color: #ff0000;">4.0</span>            <span style="color: #ff0000;">6.0</span>               <span style="color: #ff0000;">8.0</span>
disp       <span style="color: #ff0000;">160</span>       <span style="color: #ff0000;">160</span>          <span style="color: #ff0000;">108.0</span>          <span style="color: #ff0000;">258.0</span>             <span style="color: #ff0000;">360.0</span>
hp         <span style="color: #ff0000;">110</span>       <span style="color: #ff0000;">110</span>           <span style="color: #ff0000;">93.0</span>           <span style="color: #ff0000;">110.0</span>            <span style="color: #ff0000;">175.0</span></pre>
</td>
</tr>
</table>
</div>
<p>Listing 1 uses a subset of the mtcars dataset in order to conserve space on the page. You’ll see a more flexible way of transposing data when we look at the reshape package later in this article.</p>
<h3><span style="text-decoration: underline;">Aggregating data</span></h3>
<p>It’s relatively easy to collapse data in R using one or more by variables and a defined function. The format is</p>
<div class="wp_codebox">
<table>
<tr id="p89122">
<td class="line_numbers">
<pre>1
</pre>
</td>
<td class="code" id="p891code22">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">aggregate</span><span style="color: #080;">&#40;</span>x, <span style="color: #0000FF; font-weight: bold;">by</span>, FUN<span style="color: #080;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>where <em>x </em>is the data object to be collapsed, <em>by </em>is a list of variables that will be crossed to form the new observations, and <em>FUN </em>is the scalar function used to calculate summary statistics that will make up the new observation values.</p>
<p>As an example, we’ll aggregate the mtcars data by number of cylinders and gears, returning means on each of the numeric variables (see the next listing).</p>
<p><em><strong>Listing 2 Aggregating data</strong></em></p>
<div class="wp_codebox">
<table>
<tr id="p89123">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre>
</td>
<td class="code" id="p891code23">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">options</span><span style="color: #080;">&#40;</span>digits<span style="color: #080;">=</span><span style="color: #ff0000;">3</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">attach</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> aggdata <span style="color: #080;">&lt;-</span><span style="color: #0000FF; font-weight: bold;">aggregate</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span>, <span style="color: #0000FF; font-weight: bold;">by</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">list</span><span style="color: #080;">&#40;</span>cyl,gear<span style="color: #080;">&#41;</span>, FUN<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">mean</span>, na.<span style="">rm</span><span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> aggdata
  Group.1 Group.2  mpg cyl disp  hp drat   wt qsec  vs   am gear carb
<span style="color: #ff0000;">1</span>       <span style="color: #ff0000;">4</span>       <span style="color: #ff0000;">3</span> <span style="color: #ff0000;">21.5</span>   <span style="color: #ff0000;">4</span>  <span style="color: #ff0000;">120</span>  <span style="color: #ff0000;">97</span> <span style="color: #ff0000;">3.70</span> <span style="color: #ff0000;">2.46</span> <span style="color: #ff0000;">20.0</span> <span style="color: #ff0000;">1.0</span> <span style="color: #ff0000;">0.00</span>    <span style="color: #ff0000;">3</span> <span style="color: #ff0000;">1.00</span>
<span style="color: #ff0000;">2</span>       <span style="color: #ff0000;">6</span>       <span style="color: #ff0000;">3</span> <span style="color: #ff0000;">19.8</span>   <span style="color: #ff0000;">6</span>  <span style="color: #ff0000;">242</span> <span style="color: #ff0000;">108</span> <span style="color: #ff0000;">2.92</span> <span style="color: #ff0000;">3.34</span> <span style="color: #ff0000;">19.8</span> <span style="color: #ff0000;">1.0</span> <span style="color: #ff0000;">0.00</span>    <span style="color: #ff0000;">3</span> <span style="color: #ff0000;">1.00</span>
<span style="color: #ff0000;">3</span>       <span style="color: #ff0000;">8</span>       <span style="color: #ff0000;">3</span> <span style="color: #ff0000;">15.1</span>   <span style="color: #ff0000;">8</span>  <span style="color: #ff0000;">358</span> <span style="color: #ff0000;">194</span> <span style="color: #ff0000;">3.12</span> <span style="color: #ff0000;">4.10</span> <span style="color: #ff0000;">17.1</span> <span style="color: #ff0000;">0.0</span> <span style="color: #ff0000;">0.00</span>    <span style="color: #ff0000;">3</span> <span style="color: #ff0000;">3.08</span>
<span style="color: #ff0000;">4</span>       <span style="color: #ff0000;">4</span>       <span style="color: #ff0000;">4</span> <span style="color: #ff0000;">26.9</span>   <span style="color: #ff0000;">4</span>  <span style="color: #ff0000;">103</span>  <span style="color: #ff0000;">76</span> <span style="color: #ff0000;">4.11</span> <span style="color: #ff0000;">2.38</span> <span style="color: #ff0000;">19.6</span> <span style="color: #ff0000;">1.0</span> <span style="color: #ff0000;">0.75</span>    <span style="color: #ff0000;">4</span> <span style="color: #ff0000;">1.50</span>
<span style="color: #ff0000;">5</span>       <span style="color: #ff0000;">6</span>       <span style="color: #ff0000;">4</span> <span style="color: #ff0000;">19.8</span>   <span style="color: #ff0000;">6</span>  <span style="color: #ff0000;">164</span> <span style="color: #ff0000;">116</span> <span style="color: #ff0000;">3.91</span> <span style="color: #ff0000;">3.09</span> <span style="color: #ff0000;">17.7</span> <span style="color: #ff0000;">0.5</span> <span style="color: #ff0000;">0.50</span>    <span style="color: #ff0000;">4</span> <span style="color: #ff0000;">4.00</span>
<span style="color: #ff0000;">6</span>       <span style="color: #ff0000;">4</span>       <span style="color: #ff0000;">5</span> <span style="color: #ff0000;">28.2</span>   <span style="color: #ff0000;">4</span>  <span style="color: #ff0000;">108</span> <span style="color: #ff0000;">102</span> <span style="color: #ff0000;">4.10</span> <span style="color: #ff0000;">1.83</span> <span style="color: #ff0000;">16.8</span> <span style="color: #ff0000;">0.5</span> <span style="color: #ff0000;">1.00</span>    <span style="color: #ff0000;">5</span> <span style="color: #ff0000;">2.00</span>
<span style="color: #ff0000;">7</span>       <span style="color: #ff0000;">6</span>       <span style="color: #ff0000;">5</span> <span style="color: #ff0000;">19.7</span>   <span style="color: #ff0000;">6</span>  <span style="color: #ff0000;">145</span> <span style="color: #ff0000;">175</span> <span style="color: #ff0000;">3.62</span> <span style="color: #ff0000;">2.77</span> <span style="color: #ff0000;">15.5</span> <span style="color: #ff0000;">0.0</span> <span style="color: #ff0000;">1.00</span>    <span style="color: #ff0000;">5</span> <span style="color: #ff0000;">6.00</span>
<span style="color: #ff0000;">8</span>       <span style="color: #ff0000;">8</span>       <span style="color: #ff0000;">5</span> <span style="color: #ff0000;">15.4</span>   <span style="color: #ff0000;">8</span>  <span style="color: #ff0000;">326</span> <span style="color: #ff0000;">300</span> <span style="color: #ff0000;">3.88</span> <span style="color: #ff0000;">3.37</span> <span style="color: #ff0000;">14.6</span> <span style="color: #ff0000;">0.0</span> <span style="color: #ff0000;">1.00</span>    <span style="color: #ff0000;">5</span> <span style="color: #ff0000;">6.00</span></pre>
</td>
</tr>
</table>
</div>
<p>In these results, Group.1 represents the number of cylinders (4, 6, or <img src='http://www.r-statistics.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> and Group.2 represents the number of gears (3, 4, or 5). For example, cars with 4 cylinders and 3 gears have a mean of 21.5 miles per gallon (mpg).</p>
<p>When you’re using the aggregate() function , the by variables must be in a list (even if there’s only one). You can declare a custom name for the groups from within the list, for instance, using by=list(Group.cyl=cyl, Group.gears=gear).</p>
<p>The function specified can be any built-in or user-provided function. This gives the aggregate command a great deal of power. But when it comes to power, nothing beats the reshape package.</p>
<h3><span style="text-decoration: underline;">The reshape package</span></h3>
<p>The reshape package is a tremendously versatile approach to both restructuring and aggregating datasets. Because of this versatility, it can be a bit challenging to learn.</p>
<p>We’ll go through the process slowly and use a small dataset so that it’s clear what’s happening. Because reshape isn’t included in the standard installation of R, you’ll need to install it one time, using install.packages(&#8220;reshape&#8221;).</p>
<p>Basically, you’ll “melt” data so that each row is a unique ID-variable combination. Then you’ll “cast” the melted data into any shape you desire. During the cast, you can aggregate the data with any function you wish. The dataset you’ll be working with is shown in table 1.</p>
<p><em><strong>Table 1 The original dataset (mydata)</strong></em></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="37">
<div>
<p>ID</p>
</div>
</td>
<td valign="top" width="48">
<div>
<p>Time</p>
</div>
</td>
<td valign="top" width="42">
<div>
<p>X1</p>
</div>
</td>
<td valign="top" width="36">
<div>
<p>X2</p>
</div>
</td>
</tr>
<tr>
<td valign="top" width="37">1</td>
<td valign="top" width="48">1</td>
<td valign="top" width="42">5</td>
<td valign="top" width="36">6</td>
</tr>
<tr>
<td valign="top" width="37">1</td>
<td valign="top" width="48">2</td>
<td valign="top" width="42">3</td>
<td valign="top" width="36">5</td>
</tr>
<tr>
<td valign="top" width="37">2</td>
<td valign="top" width="48">1</td>
<td valign="top" width="42">6</td>
<td valign="top" width="36">1</td>
</tr>
<tr>
<td valign="top" width="37">2</td>
<td valign="top" width="48">2</td>
<td valign="top" width="42">2</td>
<td valign="top" width="36">4</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>In this dataset, the measurements are the values in the last two columns (5, 6, 3, 5, 6, 1, 2, and 4). Each measurement is uniquely identified by a combination of ID variables (in this case ID, Time, and whether the measurement is on X1 or X2). For example, the measured value 5 in the first row is uniquely identified by knowing that it’s from observation (ID) 1, at Time 1, and on variable X1.</p>
<h3>Melting</h3>
<p>When you melt a dataset, you restructure it into a format where each measured variable is in its own row, along with the ID variables needed to uniquely identify it. If you melt the data from table 1, using the following code</p>
<div class="wp_codebox">
<table>
<tr id="p89124">
<td class="line_numbers">
<pre>1
2
</pre>
</td>
<td class="code" id="p891code24">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">library</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">reshape</span><span style="color: #080;">&#41;</span>
md <span style="color: #080;">&lt;-</span> melt<span style="color: #080;">&#40;</span>mydata, id<span style="color: #080;">=</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;id&quot;</span>, <span style="color: #ff0000;">&quot;time&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>You end up with the structure shown in table 2.</p>
<p><em><strong>Table 2 The melted dataset</strong></em></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="37">
<div>
<p>ID</p>
</div>
</td>
<td valign="top" width="48">
<div>
<p>Time</p>
</div>
</td>
<td valign="top" width="78">
<div>
<p>Variable</p>
</div>
</td>
<td valign="top" width="60">
<div>
<p>Value</p>
</div>
</td>
</tr>
<tr>
<td valign="top" width="37">1</td>
<td valign="top" width="48">1</td>
<td valign="top" width="78">X1</td>
<td valign="top" width="60">5</td>
</tr>
<tr>
<td valign="top" width="37">1</td>
<td valign="top" width="48">2</td>
<td valign="top" width="78">X1</td>
<td valign="top" width="60">3</td>
</tr>
<tr>
<td valign="top" width="37">2</td>
<td valign="top" width="48">1</td>
<td valign="top" width="78">X1</td>
<td valign="top" width="60">6</td>
</tr>
<tr>
<td valign="top" width="37">2</td>
<td valign="top" width="48">2</td>
<td valign="top" width="78">X1</td>
<td valign="top" width="60">2</td>
</tr>
<tr>
<td valign="top" width="37">1</td>
<td valign="top" width="48">1</td>
<td valign="top" width="78">X2</td>
<td valign="top" width="60">6</td>
</tr>
<tr>
<td valign="top" width="37">1</td>
<td valign="top" width="48">2</td>
<td valign="top" width="78">X2</td>
<td valign="top" width="60">5</td>
</tr>
<tr>
<td valign="top" width="37">2</td>
<td valign="top" width="48">1</td>
<td valign="top" width="78">X2</td>
<td valign="top" width="60">1</td>
</tr>
<tr>
<td valign="top" width="37">2</td>
<td valign="top" width="48">2</td>
<td valign="top" width="78">X2</td>
<td valign="top" width="60">4</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Note that you must specify the variables needed to uniquely identify each measurement (ID and Time) and that the variable indicating the measurement variable names (X1 or X2) is created for you automatically.</p>
<p>Now that you have your data in a melted form, you can recast it into any shape, using the cast() function.</p>
<p>Casting</p>
<p>The cast() function starts with melted data and reshapes it using a formula that you provide and an (optional) function used to aggregate the data. The format is</p>
<div class="wp_codebox">
<table>
<tr id="p89125">
<td class="line_numbers">
<pre>1
</pre>
</td>
<td class="code" id="p891code25">
<pre class="rsplus" style="font-family:monospace;">newdata <span style="color: #080;">&lt;-</span> cast<span style="color: #080;">&#40;</span>md, <span style="color: #0000FF; font-weight: bold;">formula</span>, FUN<span style="color: #080;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>Where <em>md </em>is the melted data, <em>formula </em>describes the desired end result, and <em>FUN </em>is the (optional) aggregating function. The formula takes the form</p>
<div class="wp_codebox">
<table>
<tr id="p89126">
<td class="line_numbers">
<pre>1
</pre>
</td>
<td class="code" id="p891code26">
<pre class="rsplus" style="font-family:monospace;">rowvar1 <span style="color: #080;">+</span> rowvar2 <span style="color: #080;">+</span> …  ~  colvar1 <span style="color: #080;">+</span> colvar2 <span style="color: #080;">+</span> …</pre>
</td>
</tr>
</table>
</div>
<p>In this formula, <em>rowvar1 + rowvar2 + </em>… define the set of crossed variables that define the rows, and <em>colvar1 + colvar2 + </em>… define the set of crossed variables that define the columns. See the examples in figure 1.</p>
<p><strong><a href="http://www.r-statistics.com/wp-content/uploads/2012/01/image006.gif"><img title="The reshape package scheme" src="http://www.r-statistics.com/wp-content/uploads/2012/01/image006-300x210.gif" alt="Reshaping data with the melt() and cast() functions" width="300" height="210" /></a></strong></p>
<p><strong><em>Figure 1 Reshaping data with the melt() and cast() functions</em></strong></p>
<p>Because the formulas on the right side (d, e, and f) don’t include a function, the data is reshaped. In contrast, the examples on the left side (a, b, and c) specify the mean as an aggregating function. Thus the data are not only reshaped but aggregated as well. For example, (a) gives the means on X1 and X2 averaged over time for each observation. Example (b) gives the mean scores of X1 and X2 at Time 1 and Time 2, averaged over observations. In (c) you have the mean score for each observation at Time 1 and Time 2, averaged over X1 and X2.</p>
<p>As you can see, the flexibility provided by the melt() and cast() functions is amazing. There are many times when you’ll have to reshape or aggregate your data prior to analysis. For example, you’ll typically need to place your data in what’s called long format resembling table 2 when analyzing repeated measures data (data where multiple measures are recorded for each observation).</p>
<h3>Summary</h3>
<p>Chapter 5 of<strong> </strong><a href="http://www.manning.com/kabacoff/">R in Action</a> reviews many of the dozens of mathematical, statistical, and probability functions that are useful for manipulating data. In this article, we have briefly explored several ways of aggregating and restructuring data.</p>
<p>&nbsp;</p>
<p><em>This article first appeared as chapter 5.6 from the &#8220;<a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=21">R in action</a><strong>&#8220;</strong> book, and is published with permission from <a href="http://affiliate.manning.com/idevaffiliate.php?id=1205">Manning publishing house</a>.  Other books in this serious which you might be interested in are (see the beginning of this post for a discount code):</em></p>
<ul>
<li><a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=22">Machine Learning in Action </a>by Peter Harrington</li>
</ul>
<ul>
<li><a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&amp;url=23">Gnuplot in Action</a> (Understanding Data with Graphs) by Philipp K. Janert</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/01/aggregation-and-restructuring-data-from-r-in-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 20 R posts of 2011 (and some R-bloggers statistics)</title>
		<link>http://www.r-statistics.com/2012/01/top-20-r-posts-of-2011-and-some-r-bloggers-statistics/</link>
		<comments>http://www.r-statistics.com/2012/01/top-20-r-posts-of-2011-and-some-r-bloggers-statistics/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 17:15:02 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R bloggers]]></category>
		<category><![CDATA[R community]]></category>
		<category><![CDATA[R links]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=880</guid>
		<description><![CDATA[R-bloggers.com is now two years young. The site is an (unofficial) online R journal written by bloggers who agreed to contribute their R articles to the site. In this post I wish to celebrate R-bloggers’ second birthmounth by sharing with you: Links to the top 20 posts of 2011 Statistics on “how well” R-bloggers did [...] <p class="read-more"><a href="http://www.r-statistics.com/2012/01/top-20-r-posts-of-2011-and-some-r-bloggers-statistics/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.r-bloggers.com/">R-bloggers.com</a> is now two years young. The site is an (unofficial) online R journal written by bloggers who agreed to contribute their R articles to the site.<br />
In this post I wish to celebrate R-bloggers’ second birthmounth by sharing with you:</p>
<ol>
<li>Links to the top 20 posts of 2011</li>
<li>Statistics on “how well” R-bloggers did this year</li>
<li>An invitation for sponsors/supporters to help keep the site alive</li>
</ol>
<div><span id="more-880"></span></div>
<h3>1. Top 24 R posts of 2011</h3>
<p>R-bloggers’ success is largely owed to the content submitted by the R bloggers themselves.  The R community currently has almost <strong>300 active R bloggers</strong> (links to the blogs are clearly visible in the right navigation bar on the <a href="http://www.r-bloggers.com/">R-bloggers homepage</a>).  In the past year, these bloggers wrote over 2800 posts about R.</p>
<p>Here is a <strong>list of the top visited posts</strong> on the site in 2011:</p>
<ol>
<li><a href="http://www.r-bloggers.com/how-much-of-r-is-written-in-r/%20">How much of r is written in r</a></li>
<li><a href="http://www.r-bloggers.com/cpu-and-gpu-trends-over-time/%20">Cpu and gpu trends over time</a></li>
<li><a href="http://www.r-bloggers.com/select-operations-on-r-data-frames/%20">Select operations on r data frames</a></li>
<li><a href="http://www.r-bloggers.com/getting-started-with-sweave-r-latex-eclipse-statet-texlipse/%20">Getting started with sweave r latex eclipse statet texlipse</a></li>
<li><a href="http://www.r-bloggers.com/delete-rows-from-r-data-frame/%20">Delete rows from r data frame</a></li>
<li><a href="http://www.r-bloggers.com/amanda-cox-on-how-the-new-york-times-graphics-department-uses-r/%20">Amanda cox on how the new york times graphics department uses r</a></li>
<li><a href="http://www.r-bloggers.com/hipster-programming-languages/%20">Hipster programming languages</a></li>
<li><a href="http://www.r-bloggers.com/opendata-r-google-easy-maps/%20">Opendata r google easy maps</a></li>
<li><a href="http://www.r-bloggers.com/new-r-generated-video-has-stackoverflow-posting-behavior-changed-over-time/%20">New r generated video has stackoverflow posting behavior changed over time</a></li>
<li><a href="http://www.r-bloggers.com/sna-visualising-an-email-box-with-r/%20">SNA visualising an email box with r</a></li>
<li><a href="http://www.r-bloggers.com/100-prisoners-100-lines-of-code/%20">100 prisoners 100 lines of code</a></li>
<li><a href="http://www.r-bloggers.com/google-ai-challenge-languages-used-by-the-best-programmers/%20">Google ai challenge languages used by the best programmers</a></li>
<li><a href="http://www.r-bloggers.com/basics-on-markov-chain-for-parents/%20">Basics on markov chain for parents</a></li>
<li><a href="http://www.r-bloggers.com/top-10-algorithms-in-data-mining/%20">Top 10 algorithms in data mining</a></li>
<li><a href="http://www.r-bloggers.com/a-million-random-digits-review-of-reviews/%20">A million random digits review of reviews</a></li>
<li><a href="http://www.r-bloggers.com/character-occurrence-in-passwords/%20">Character occurrence in passwords</a></li>
<li><a href="http://www.r-bloggers.com/setting-graph-margins-in-r-using-the-par-function-and-lots-of-cow-milk/%20">Setting graph margins in r using the par function and lots of cow milk</a></li>
<li><a href="http://www.r-bloggers.com/the-new-r-compiler-package-in-r-2-13-0-some-first-experiments/%20">The new r compiler package in r 2 13 0 some first experiments</a></li>
<li><a href="http://www.r-bloggers.com/tutorial-principal-components-analysis-pca-in-r/%20">Tutorial principal components analysis pca in r</a></li>
<li><a href="http://www.r-bloggers.com/making-guis-using-c-and-r-with-the-help-of-r-net/%20">Making guis using c and r with the help of r net</a></li>
</ol>
<h3>2. Statistics – how well did R-bloggers do this year</h3>
<p>There are several matrices one can consider when evaluating the success of a website.  I’ll present a few of them here and will begin by talking about the visitors to the site.</p>
<p>This year, <strong>the site was visited by</strong> over 665,000 “Unique Visitors.”  There was a total of over 1.4 million visits and over 2.8 million page-views.  People have surfed the site from over 200 countries, with the greatest number of visitors coming from the United States (~40%) and then followed by the United Kingdom (6.9%), Germany (6.6%), Canada (4.7%), France (3.3%), and other countries.</p>
<p>The site has received between 15,000 to 45,000 visits a week in the past few months, and I suspect this number will remain stable in the next few months (unless something very interesting will happen).</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2012/01/Visitors-Overview-Google-Analytics-Google-Chrome_2012-01-01_18-33-41.png"><img class="alignnone size-medium wp-image-881" title="Visitors Overview - Google Analytics - Google Chrome_2012-01-01_18-33-41" src="http://www.r-statistics.com/wp-content/uploads/2012/01/Visitors-Overview-Google-Analytics-Google-Chrome_2012-01-01_18-33-41-300x88.png" alt="" width="300" height="88" /></a></p>
<p>I believe this number will stay constant thanks to visitors’ loyalty: 55% of the site’s visits came from returning users.</p>
<p>Another indicator of reader loyalty is the number of subscribers to R-bloggers as counted by feedburner, which includes both RSS readers and e-mail subscribers.  The range of subscribers is estimated to be between 5600 to 5900.</p>
<p>Thus, I am very happy to see that R-bloggers continues to succeed in offering a real service to the global R users community.</p>
<h3>3. Invitation to sponsor/advertise on R-bloggers</h3>
<p>This year I was sadly accused by google adsense of click fraud (which I did not do, but have no way of proving my innocence).  Therefor, I am no longer able to use google adsense to sustain R-bloggers high monthly bills, and I turned to rely on direct  sponsoring of R-bloggers.</p>
<p><strong>If you are interested in sponsoring/placing-ads/supporting R-bloggers, then you are welcome to <a href="http://www.r-statistics.com/contact-me/">contact me</a>.</strong></p>
<p>Happy new year!<br />
Yours,<br />
<a href="http://www.r-statistics.com/about/">Tal Galili</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/01/top-20-r-posts-of-2011-and-some-r-bloggers-statistics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>data.frame objects in R (via “R in Action”)</title>
		<link>http://www.r-statistics.com/2011/12/data-frame-objects-in-r-via-r-in-action/</link>
		<comments>http://www.r-statistics.com/2011/12/data-frame-objects-in-r-via-r-in-action/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 22:02:04 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R bloggers]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[data frame]]></category>
		<category><![CDATA[data frames]]></category>
		<category><![CDATA[R book]]></category>
		<category><![CDATA[R classes]]></category>
		<category><![CDATA[R in action]]></category>
		<category><![CDATA[R objects]]></category>
		<category><![CDATA[R tutorial]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=865</guid>
		<description><![CDATA[The followings introductory post is intended for new users of R.  It deals with R data frames: what they are, and how to create, view, and update them. This is a guest article by Dr. Robert I. Kabacoff, the founder of (one of) the first online R tutorials websites: Quick-R.  Kabacoff has recently published the book &#8221;R [...] <p class="read-more"><a href="http://www.r-statistics.com/2011/12/data-frame-objects-in-r-via-r-in-action/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>The followings introductory post is intended for new users of R.  It deals with R data frames: what they are, and how to create, view, and update them.</strong></p>
<p>This is a guest article by Dr. <a href="http://www.statmethods.net/about/author.html">Robert I. Kabacoff</a>, the founder of (one of) the first online R tutorials websites: <a href="http://www.statmethods.net/interface/index.html">Quick-R</a>.  Kabacoff has recently published the book &#8221;<strong><a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&#038;url=21">R in Action</a></strong>&#8220;, providing a detailed walk-through for the R language based on various examples for illustrating R’s features (data manipulation, statistical methods, graphics, and so on&#8230;)</p>
<p><a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&#038;url=21"><img src="http://www.r-statistics.com/wp-content/uploads/2011/12/kabacoff_cover150.jpg" alt="" title="R in Action cover image" width="150" height="188" class="alignleft size-full wp-image-874" /></a></p>
<p>For readers of this blog, there is a<strong> 38% discount</strong> off <a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&#038;url=21">the &#8220;R in Action&#8221; book</a> (as well as all other eBooks, pBooks and MEAPs at <a href="http://affiliate.manning.com/idevaffiliate.php?id=1205">Manning publishing house</a>), simply by using the code <em><strong>rblogg38 </strong></em>when reaching checkout.</p>
<p>Let us now talk about data frames:<br />
<span id="more-865"></span><br />
<u></p>
<h3>Data Frames</h3>
<p></u><br />
A data frame is more general than a matrix in that different columns can contain different modes of data (numeric, character, and so on). It’s similar to the datasets you’d typically see in SAS, SPSS, and Stata. Data frames are the most common data structure you’ll deal with in R.</p>
<p>The patient dataset in table 1 consists of numeric and character data.</p>
<p><em>Table 1: A patient dataset</em></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="67">
<div>
<p>PatientID</p>
</div>
</td>
<td valign="top" width="78">
<div>
<p>AdmDate</p>
</div>
</td>
<td valign="top" width="42">
<div>
<p>Age</p>
</div>
</td>
<td valign="top" width="60">
<div>
<p>Diabetes</p>
</div>
</td>
<td valign="top" width="66">
<div>
<p>Status</p>
</div>
</td>
</tr>
<tr>
<td valign="top" width="67">1</td>
<td valign="top" width="78">10/15/2009</td>
<td valign="top" width="42">25</td>
<td valign="top" width="60">Type1</td>
<td valign="top" width="66">Poor</td>
</tr>
<tr>
<td valign="top" width="67">2</td>
<td valign="top" width="78">11/01/2009</td>
<td valign="top" width="42">34</td>
<td valign="top" width="60">Type2</td>
<td valign="top" width="66">Improved</td>
</tr>
<tr>
<td valign="top" width="67">3</td>
<td valign="top" width="78">10/21/2009</td>
<td valign="top" width="42">28</td>
<td valign="top" width="60">Type1</td>
<td valign="top" width="66">Excellent</td>
</tr>
<tr>
<td valign="top" width="67">4</td>
<td valign="top" width="78">10/28/2009</td>
<td valign="top" width="42">52</td>
<td valign="top" width="60">Type1</td>
<td valign="top" width="66">Poor</td>
</tr>
</tbody>
</table>
<p>Because there are multiple modes of data, you can’t contain this data in a matrix. In this case, a data frame would be the structure of choice.</p>
<p>A data frame is created with the data.frame() function:</p>
<div class="wp_codebox">
<table>
<tr id="p86538">
<td class="line_numbers">
<pre>1
</pre>
</td>
<td class="code" id="p865code38">
<pre class="rsplus" style="font-family:monospace;">mydata <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span><span style="color: #080;">&#40;</span>col1, col2, col3,…<span style="color: #080;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>where <em>col1, col2, col3, </em>… are column vectors of any type (such as character, numeric, or logical). Names for each column can be provided with the names function.</p>
<p>The following listing makes this clear.</p>
<p><strong>Listing 1 Creating a data frame</strong></p>
<div class="wp_codebox">
<table>
<tr id="p86539">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
</pre>
</td>
<td class="code" id="p865code39">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> patientID <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span>, <span style="color: #ff0000;">2</span>, <span style="color: #ff0000;">3</span>, <span style="color: #ff0000;">4</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> age <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">25</span>, <span style="color: #ff0000;">34</span>, <span style="color: #ff0000;">28</span>, <span style="color: #ff0000;">52</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> diabetes <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Type1&quot;</span>, <span style="color: #ff0000;">&quot;Type2&quot;</span>, <span style="color: #ff0000;">&quot;Type1&quot;</span>, <span style="color: #ff0000;">&quot;Type1&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> status <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Poor&quot;</span>, <span style="color: #ff0000;">&quot;Improved&quot;</span>, <span style="color: #ff0000;">&quot;Excellent&quot;</span>, <span style="color: #ff0000;">&quot;Poor&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> patientdata <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span><span style="color: #080;">&#40;</span>patientID, age, diabetes, status<span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> patientdata
  patientID age diabetes status
<span style="color: #ff0000;">1</span>         <span style="color: #ff0000;">1</span>  <span style="color: #ff0000;">25</span>    Type1 Poor
<span style="color: #ff0000;">2</span>         <span style="color: #ff0000;">2</span>  <span style="color: #ff0000;">34</span>    Type2 Improved
<span style="color: #ff0000;">3</span>         <span style="color: #ff0000;">3</span>  <span style="color: #ff0000;">28</span>    Type1 Excellent
<span style="color: #ff0000;">4</span>         <span style="color: #ff0000;">4</span>  <span style="color: #ff0000;">52</span>    Type1 Poor</pre>
</td>
</tr>
</table>
</div>
<p>Each column must have only one mode, but you can put columns of different modes together to form the data frame. Because data frames are close to what analysts typically think of as datasets, we’ll use the terms columns and variables interchangeably when discussing data frames.</p>
<p>There are several ways to identify the elements of a data frame. You can use the subscript notation or you can specify column names. Using the patientdata data frame created earlier, the following listing demonstrates these approaches.</p>
<p><strong>Listing 2 Specifying elements of a data frame</strong></p>
<div class="wp_codebox">
<table>
<tr id="p86540">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre>
</td>
<td class="code" id="p865code40">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> patientdata<span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">2</span><span style="color: #080;">&#93;</span>
  patientID age
<span style="color: #ff0000;">1</span>         <span style="color: #ff0000;">1</span>  <span style="color: #ff0000;">25</span>
<span style="color: #ff0000;">2</span>         <span style="color: #ff0000;">2</span>  <span style="color: #ff0000;">34</span>
<span style="color: #ff0000;">3</span>         <span style="color: #ff0000;">3</span>  <span style="color: #ff0000;">28</span>
<span style="color: #ff0000;">4</span>         <span style="color: #ff0000;">4</span>  <span style="color: #ff0000;">52</span>
<span style="color: #080;">&gt;</span> patientdata<span style="color: #080;">&#91;</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;diabetes&quot;</span>, <span style="color: #ff0000;">&quot;status&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>
  diabetes status
<span style="color: #ff0000;">1</span>    Type1 Poor
<span style="color: #ff0000;">2</span>    Type2 Improved
<span style="color: #ff0000;">3</span>    Type1 Excellent
<span style="color: #ff0000;">4</span>    Type1 Poor
<span style="color: #080;">&gt;</span> patientdata$age    <span style="color: #228B22;">#age variable in the patient data frame</span>
<span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span> <span style="color: #ff0000;">25</span> <span style="color: #ff0000;">34</span> <span style="color: #ff0000;">28</span> <span style="color: #ff0000;">52</span></pre>
</td>
</tr>
</table>
</div>
<p>The $ notation in the third example is used to indicate a particular variable from a given data frame. For example, if you want to cross-tabulate diabetes type by status, you could use the following code:</p>
<div class="wp_codebox">
<table>
<tr id="p86541">
<td class="line_numbers">
<pre>1
2
3
4
5
</pre>
</td>
<td class="code" id="p865code41">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">table</span><span style="color: #080;">&#40;</span>patientdata$diabetes, patientdata$status<span style="color: #080;">&#41;</span>
&nbsp;
        Excellent Improved Poor
  Type1         <span style="color: #ff0000;">1</span>        <span style="color: #ff0000;">0</span>    <span style="color: #ff0000;">2</span>
  Type2         <span style="color: #ff0000;">0</span>        <span style="color: #ff0000;">1</span>    <span style="color: #ff0000;">0</span></pre>
</td>
</tr>
</table>
</div>
<p>It can get tiresome typing patientdata$ at the beginning of every variable name, so shortcuts are available. You can use either the attach() and detach() or with() functions to simplify your code.</p>
<h3>attach, detach, and with</h3>
<p>The attach() function adds the data frame to the R search path. When a variable name is encountered, data frames in the search path are checked in order to locate the variable. Using a sample (mtcars) data frame, you could use the following code to obtain summary statistics for automobile mileage (mpg), and plot this variable against engine displacement (disp), and weight (wt):</p>
<div class="wp_codebox">
<table>
<tr id="p86542">
<td class="line_numbers">
<pre>1
2
3
</pre>
</td>
<td class="code" id="p865code42">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">summary</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span>$mpg<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span>$mpg, <span style="color: #CC9900; font-weight: bold;">mtcars</span>$disp<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span>$mpg, <span style="color: #CC9900; font-weight: bold;">mtcars</span>$wt<span style="color: #080;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>This could also be written as</p>
<div class="wp_codebox">
<table>
<tr id="p86543">
<td class="line_numbers">
<pre>1
2
3
4
5
</pre>
</td>
<td class="code" id="p865code43">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">attach</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span><span style="color: #080;">&#41;</span>
  <span style="color: #0000FF; font-weight: bold;">summary</span><span style="color: #080;">&#40;</span>mpg<span style="color: #080;">&#41;</span>
  <span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span>mpg, disp<span style="color: #080;">&#41;</span>
  <span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span>mpg, wt<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">detach</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span><span style="color: #080;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>The detach() function removes the data frame from the search path. Note that detach() does nothing to the data frame itself. The statement is optional but is good programming practice and should be included routinely.</p>
<p>The limitations with this approach are evident when more than one object can have the same name. Consider the following code:</p>
<div class="wp_codebox">
<table>
<tr id="p86544">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
</pre>
</td>
<td class="code" id="p865code44">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> mpg <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">25</span>, <span style="color: #ff0000;">36</span>, <span style="color: #ff0000;">47</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">attach</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span><span style="color: #080;">&#41;</span>
&nbsp;
The following object<span style="color: #080;">&#40;</span>s<span style="color: #080;">&#41;</span> are masked _by_ ‘.<span style="">GlobalEnv</span>’<span style="color: #080;">:</span> mpg
<span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span>mpg, wt<span style="color: #080;">&#41;</span>
Error <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #0000FF; font-weight: bold;">xy.<span style="">coords</span></span><span style="color: #080;">&#40;</span>x, y, xlabel, ylabel, <span style="color: #0000FF; font-weight: bold;">log</span><span style="color: #080;">&#41;</span> <span style="color: #080;">:</span>
  ‘x’ and ‘y’ lengths differ
<span style="color: #080;">&gt;</span> mpg
<span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span> <span style="color: #ff0000;">25</span> <span style="color: #ff0000;">36</span> <span style="color: #ff0000;">47</span></pre>
</td>
</tr>
</table>
</div>
<p>Here we already have an object named mpg in our environment when the mtcars data frame is attached. In such cases, the original object takes precedence, which isn’t what you want. The plot statement fails because mpg has 3 elements and disp has 32 elements. The attach() and detach() functions are best used when you’re analyzing a single data frame and you’re unlikely to have multiple objects with the same name. In any case, be vigilant for warnings that say that objects are being masked.</p>
<p>An alternative approach is to use the with() function. You could write the previous example as</p>
<div class="wp_codebox">
<table>
<tr id="p86545">
<td class="line_numbers">
<pre>1
2
3
4
5
</pre>
</td>
<td class="code" id="p865code45">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">with</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span>, <span style="color: #080;">&#123;</span>
  <span style="color: #0000FF; font-weight: bold;">summary</span><span style="color: #080;">&#40;</span>mpg, disp, wt<span style="color: #080;">&#41;</span>
  <span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span>mpg, disp<span style="color: #080;">&#41;</span>
  <span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span>mpg, wt<span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>In this case, the statements within the {} brackets are evaluated with reference to the mtcars data frame. You don’t have to worry about name conflicts here. If there’s only one statement (for example, summary(mpg)), the {} brackets are optional.</p>
<p>The limitation of the with() function is that assignments will only exist within the function brackets. Consider the following:</p>
<div class="wp_codebox">
<table>
<tr id="p86546">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
</pre>
</td>
<td class="code" id="p865code46">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">with</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span>, <span style="color: #080;">&#123;</span>
   stats <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">summary</span><span style="color: #080;">&#40;</span>mpg<span style="color: #080;">&#41;</span>
   stats
  <span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>
   Min. 1st Qu. <span style="">Median</span> Mean 3rd Qu. <span style="">Max</span>.
  <span style="color: #ff0000;">10.40</span> <span style="color: #ff0000;">15.43</span> <span style="color: #ff0000;">19.20</span> <span style="color: #ff0000;">20.09</span> <span style="color: #ff0000;">22.80</span> <span style="color: #ff0000;">33.90</span>
<span style="color: #080;">&gt;</span> stats
Error<span style="color: #080;">:</span> object ‘stats’ not found</pre>
</td>
</tr>
</table>
</div>
<p>If you need to create objects that will exist outside of the with() construct, use the special assignment operator &lt;&lt;- instead of the standard one (&lt;-). It will save the object to the global environment outside of the with() call. This can be demonstrated with the following code:</p>
<div class="wp_codebox">
<table>
<tr id="p86547">
<td class="line_numbers">
<pre>1
2
3
4
5
6
7
8
9
</pre>
</td>
<td class="code" id="p865code47">
<pre class="rsplus" style="font-family:monospace;"><span style="color: #080;">&gt;</span> <span style="color: #0000FF; font-weight: bold;">with</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">mtcars</span>, <span style="color: #080;">&#123;</span>
   nokeepstats <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">summary</span><span style="color: #080;">&#40;</span>mpg<span style="color: #080;">&#41;</span>
   keepstats <span style="color: #080;">&lt;&lt;-</span> <span style="color: #0000FF; font-weight: bold;">summary</span><span style="color: #080;">&#40;</span>mpg<span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&gt;</span> nokeepstats
Error<span style="color: #080;">:</span> object ‘nokeepstats’ not found
<span style="color: #080;">&gt;</span> keepstats
   Min. 1st Qu. <span style="">Median</span> Mean 3rd Qu. <span style="">Max</span>.
    <span style="color: #ff0000;">10.40</span> <span style="color: #ff0000;">15.43</span> <span style="color: #ff0000;">19.20</span> <span style="color: #ff0000;">20.09</span> <span style="color: #ff0000;">22.80</span> <span style="color: #ff0000;">33.90</span></pre>
</td>
</tr>
</table>
</div>
<p>Most books on R recommend using with() over attach(). I think that ultimately the choice is a matter of preference and should be based on what you’re trying to achieve and your understanding of the implications.</p>
<h3>Case identifiers</h3>
<p>In the patient data example, patientID is used to identify individuals in the dataset. In R, case identifiers can be specified with a rowname option in the data frame function. For example, the statement</p>
<div class="wp_codebox">
<table>
<tr id="p86548">
<td class="line_numbers">
<pre>1
2
</pre>
</td>
<td class="code" id="p865code48">
<pre class="rsplus" style="font-family:monospace;">patientdata <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span><span style="color: #080;">&#40;</span>patientID, age, diabetes, status,
   <span style="color: #0000FF; font-weight: bold;">row.<span style="">names</span></span><span style="color: #080;">=</span>patientID<span style="color: #080;">&#41;</span></pre>
</td>
</tr>
</table>
</div>
<p>specifies patientID as the variable to use in labeling cases on various printouts and graphs produced by R.</p>
<h3>Summary</h3>
<p>One of the most challenging tasks in data analysis is data preparation. R provides various structures for holding data and many methods for importing data from both keyboard and external sources. One of those structures is data frames, which we covered here. Your ability to specify elements of these structures via the bracket notation is particularly important in selecting, subsetting, and transforming data.</p>
<p>R offers a wealth of functions for accessing external data. This includes data from flat files, web files, statistical packages, spreadsheets, and databases. Note that you can also export data from R into these external formats. We showed you how to use either the attach() and detach() or with() functions to simplify your code.</p>
<p><em>This article first appeared as chapter 2.2.4 from the &#8220;<a href="http://affiliate.manning.com/idevaffiliate.php?id=1205&#038;url=21">R in action</a><strong>&#8220;</strong> book, and is published with permission from <a href="http://affiliate.manning.com/idevaffiliate.php?id=1205">Manning publishing house</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2011/12/data-frame-objects-in-r-via-r-in-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UseR! 2011 slides and videos – on one page</title>
		<link>http://www.r-statistics.com/2011/12/user-2011-slides-and-videos-on-one-page/</link>
		<comments>http://www.r-statistics.com/2011/12/user-2011-slides-and-videos-on-one-page/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 22:15:31 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R bloggers]]></category>
		<category><![CDATA[R community]]></category>
		<category><![CDATA[R links]]></category>
		<category><![CDATA[R talks]]></category>
		<category><![CDATA[useR]]></category>
		<category><![CDATA[useR 2011]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=858</guid>
		<description><![CDATA[Links to slides and talks from useR 2011 - all organized in one page.<p class="read-more"><a href="http://www.r-statistics.com/2011/12/user-2011-slides-and-videos-on-one-page/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I was recently <a href="http://applyr.blogspot.com/2011/12/user-2011-slides-are-available.html">reminded </a>that the wonderful team at warwick University made sure to put online many of the slides (and <a href="http://www.r-bloggers.com/RUG/category/user-conference/">some videos</a>) of talks from the recent <a href="http://www.warwick.ac.uk/statsdept/useR-2011/index.html">useR 2011</a> conference.  You can browse through the talks by going between the <a href="http://www.warwick.ac.uk/statsdept/user-2011/schedule/index.html">timetables</a> (where it will be the most updated, if more slides will be added later), but I thought it might be more convenient for some of you to have the links to all the talks (with slides/videos) in one place.</p>
<p>I am grateful for all of the wonderful people who put their time in making such an amazing event (organizers, speakers, attendees), and also for the many speakers who made sure to share their talk/slides online for all of us to reference.  I hope to see this open-slides trend will continue in the upcoming useR conferences&#8230;</p>
<p>Bellow are all the links:</p>
<p><span id="more-858"></span></p>
<p><strong>Tuesday 16th August</strong><strong></strong></p>
<div align="center">
<table border="1" cellpadding="0">
<tbody>
<tr>
<td>
<p align="center"><strong>09:50 &#8211; 10:50</strong></p>
</td>
<td colspan="2"><strong>Kaleidoscope Ia, MS.03, Chair: Dieter Menne</strong></td>
<td width="67"></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Claudia Beleites</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/300311-beleitesclaudia.pdf">Spectroscopic Data in R and Validation of Soft Classifiers: Classifying Cells and Tissues by Raman Spectroscopy</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_0950_Kaleid_Ia_1-Beleites.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Jonathan Rosenblatt</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-abstract_0-8.pdf">Revisiting Multi-Subject Random Effects in fMRI</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_0950_Kaleid_Ia_1-Rosenblatt.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Zoe Hoare</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/300311-hoarezoe.pdf">Putting the R into Randomisation</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_0950_Kaleid_Ia_1-Hoare.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Kaleidoscope Ib, MS.01, Chair: Simon Urbanek</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Markus Gesmann</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/270211-gesmannmarkus.pdf">Using the Google Visualisation API with R</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_0950_Kaleid_Ib_2-Gesmann.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Kaleidoscope Ic, MS.02, Chair: Achim Zeileis</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">David Smith</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-user2011_smith_r_ecosystem.pdf">The R Ecosystem</a></td>
<td valign="top" width="67">[<a href="http://prezi.com/s1qrgfm9ko4i/the-r-ecosystem/">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">E. James Harner</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-rc2.pdf">Rc2: R collaboration in the cloud</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_0950_Kaleid_Ic_2-Harner.pdf">Slides</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>11:15 &#8211; 12:35</strong></p>
</td>
<td colspan="2"><strong>Portfolio Management, B3.02, Chair: Patrick Burns</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Jagrata Minardi</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/040411-user2011_abstract_jm_01.pdf">R in the Practice of Risk Management Today</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1115_FocusI_1-PortfolioMgmt_1-Minardi.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Bioinformatics and High-Throughput Data, B3.03, Chair: Hervé Pagès</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Thierry Onkelinx</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/290311-onkelinxthierry.pdf">AFLP: generating objective and repeatable genetic data</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1115_FocusI_2-Bioinformatics_1-Onkelinx.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>High Performance Computing, MS.03, Chair: Stefan Theussl</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Willem Ligtenberg</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-gpu_computing_and_r.pdf">GPU computing and R</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1115_FocusI_3-HighPerfComp_1-Ligtenberg.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Manuel Quesada</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/300311-user2011_obansoft.pdf">OBANSoft: integrated software for Bayesian statistics and high performance computing with R</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1115_FocusI_3-HighPerfComp_4-Quesada.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Reporting Technologies and Workflows, MS.01, Chair: Martin Mächler</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Andreas Leha</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-lehaandreas.pdf">The Emacs Org-mode: Reproducible Research and Beyond</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1115_FocusI_4-ReportingWorkflows_3-Leha.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Teaching, MS.02, Chair: Jay G. Kerns</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Ian Holliday</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-hollidayian.pdf">Teaching Statistics to Psychology Students using Reproducible Computing package RC and supporting Peer Review Framework</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1115_FocusI_5-Teaching_1-Holliday.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Achim Zeileis</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/270311-abstract.pdf">Automatic generation of exams in R</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1115_FocusI_5-Teaching_3-Zeileis.pdf">Slides</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>14:00 &#8211; 14:45</strong></p>
</td>
<td colspan="2"><strong>Invited Talk, MS.01/MS.02, Chair: David Firth</strong></td>
<td></td>
</tr>
<tr>
<td valign="top" width="77"></td>
<td valign="top" width="197">Ulrike Grömping</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/invited/user2011_Groemping.pdf">Design of Experiments in R</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Invited/Gromping-Design_of_Experiments.pdf">Slides</a>] [<a href="http://www.r-bloggers.com/RUG/2011/10/user-2011-ulrike-gromping-design-of-experiments/">Video</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>14:45 &#8211; 15:30</strong></p>
</td>
<td colspan="2"><strong>Invited Talk, MS.01/MS.02, Chair: David Firth</strong></td>
<td></td>
</tr>
<tr>
<td valign="top" width="77"></td>
<td valign="top" width="197">Jonathan Rougier</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/invited/user2011_Rougier.pdf">Nomograms for visualising relationships between three variables</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Invited/Rougier_Nomograms.pdf">Slides</a>] [<a href="http://www.r-bloggers.com/RUG/2011/10/user-2011-jonathan-rougier-nomograms-for-visualising-relationships-between-three-variables/">Video</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>16:00 &#8211; 17:00</strong></p>
</td>
<td colspan="2"><strong>Modelling Systems and Networks, B3.02, Chair: Jonathan Rougier</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Rachel Oxlade</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/100311-oxladerachel.pdf">An S4 Object structure for emulation &#8211; the approximation of complex functions</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1600_FocusII_1-ModelSysNet_1-Oxlade.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Christophe Dutang</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/290311-dutangchristophe.pdf">Computation of generalized Nash equilibria</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1600_FocusII_1-ModellingSystemsNet_3-Dutang.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Visualisation, MS.04, Chair: Antony Unwin</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Andrej Blejec</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-blejecandrej.pdf">animatoR: dynamic graphics in R</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1600_FocusII_3-Visual_1-Blejec.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Richard M. Heiberger</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/240311-heibergerrichard.pdf">Graphical Syntax for Structables and their Mosaic Plots</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1600_FocusII_3-Visual_2-Heiberger.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Dimensionality Reduction and Variable Selection, MS.01, Chair: Matthias Schmid</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Marie Chavent</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-chaventmarie.pdf">ClustOfVar: an R package for the clustering of variables</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1600_FocusII_5-DimReduction_1-Chavent.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Jürg Schelldorfer</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/290311-glmmlasso.pdf">Variable Screening and Parameter Estimation for High-Dimensional Generalized Linear Mixed Models Using l1-Penalization</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1600_FocusII_5-DimReduction_2-Schelldorfer.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Benjamin Hofner</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-hofnerbenjamin.pdf">gamboostLSS: boosting generalized additive models for location, scale and shape</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1600_FocusII_5-DimReduction_3-Hofner.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Business Management, MS.02, Chair: Enrico Branca</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Marlene S. Marchena</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/100311-marchenamarlene.pdf">SCperf: An inventory management package for R</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1600_FocusII_6-Business_1-Marchena.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Pairach Piboonrungroj</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/080211-user2011_using_r_to_test_tce_in_tsc_sem.pdf">Using R to test transaction cost measurement for supply chain relationship: A structural equation model</a></td>
<td valign="top" width="67">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/16Aug_1600_FocusII_6-Business_2-Piboonrungroj.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="197">Fabrizio Ortolani</td>
<td valign="top" width="237"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/040411-millo_ortolani.pdf">Integrating R and Excel for automatic business forecasting</a></td>
<td></td>
</tr>
<tr>
<td>
<p align="center"><strong>17:05 &#8211; 18:05</strong></p>
</td>
<td colspan="2"><a href="http://www.warwick.ac.uk/statsdept/user-2011/schedule/lightning.html"><strong>Lightning Talks</strong></a></td>
<td>(see bellow)</td>
</tr>
</tbody>
</table>
</div>
<div align="center">
<hr align="center" noshade="noshade" size="2" width="100%" />
</div>
<p><strong>Lightning Talks</strong></p>
<ul>
<li>Community and Communication, MS.02, Chair: Ashley Ford</li>
<ul>
<li><strong style="font-size: 13px;">George Zhang:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">China R user conference [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/1-CommunityAndCommun_3-Zhang.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
<li><strong style="font-size: 13px;">Tal Galili:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">Blogging and R &#8211; present and future [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.r-statistics.com/2011/10/the-present-and-future-of-the-r-blogosphere-a-7-minute-lightning-talk-from-user2011/">Link</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
<li><strong style="font-size: 13px;">Markus Schmidberger:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">Get your R application onto a powerful and fully-configured Cloud Computing environment in less than 5 minutes. [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/1-CommunityAndCommun_7-Schmidberger.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
<li><strong style="font-size: 13px;">Eirini Koutoumanou:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">Teaching R to Non Package Literate Users [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/1-CommunityAndCommunication_9-Koutoumanou.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
<li><strong style="font-size: 13px;">Randall Pruim:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">Teaching Statistics using the mosaic Package [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/1-CommunityAndCommun_10-Prium.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
</ul>
<li>Statistics and Programming, MS.01, Chair: Elke Thönnes</li>
<ul>
<li><strong style="font-size: 13px;">Toby Dylan Hocking:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">Fast, named capture regular expressions in R2.14 [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/2-StatisticsAndProg_3-Hocking.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
<li><strong style="font-size: 13px;">John C. Nash:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">Developments in optimization tools for R [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/2-StatisticsAndProg_4-Nash.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
<li><strong style="font-size: 13px;">Christophe Dutang:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">A Unified Approach to fit probability distributions [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/2-StatisticsAndProg_5-Dutang.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
</ul>
<li>Package Showcase, MS.03, Chair: Jennifer Rogers</li>
<ul>
<li><strong style="font-size: 13px;">James Foadi:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">cRy: statistical applications in macromolecular crystallography [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/3-PackageShowcase_3-Foadi.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
<li><strong style="font-size: 13px;">Emilio López:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">Six Sigma is possible with R [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/3-PackageShowcase_5-Lopez.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
<li><strong style="font-size: 13px;">Jonathan Clayden:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">Medical image processing with TractoR [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/3-PackageShowcase_6-Clayden.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
<li><strong style="font-size: 13px;">Richard A. Bilonick:</strong><strong style="font-size: 13px;"> </strong><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">Using merror 2.0 to Analyze Measurement Error and Determine Calibration Curves [</span><a style="font-size: 13px; font-weight: normal;" href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Lightening/3-PackageShowcase_8-Bilonick.pdf">Slides</a><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">]</span></li>
</ul>
</ul>
<p><strong>Wednesday 17th August</strong></p>
<div align="center">
<table border="1" cellpadding="0">
<tbody>
<tr>
<td>
<p align="center"><strong>09:00 &#8211; 09:50</strong></p>
</td>
<td colspan="2"><strong>Invited Talk, MS.01/MS.02, Chair: Ioannis Kosmidis</strong></td>
<td width="52"></td>
</tr>
<tr>
<td valign="top" width="88"></td>
<td valign="top" width="136">Lee E. Edlefsen</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/invited/user2011_Edlefsen.pdf">Scalable Data Analysis in R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Invited/Edlefsen-Scalable_Data_Analysis.pdf">Slides</a>] [<a href="http://www.r-bloggers.com/RUG/2011/10/user-2011-lee-e-edlefsen-scalable-data-analysis-in-r/">Video</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>11:15 &#8211; 12:35</strong></p>
</td>
<td colspan="2"><strong>Spatio-Temporal Statistics, B3.02, Chair: Julian Stander</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Nikolaus Umlauf</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-umlaufnikolaus.pdf">Structured Additive Regression Models: An R Interface to BayesX</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII_1-SpatioTempStat_3-Umlauf.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Molecular and Cell Biology, B3.03, Chair: Andrea Foulkes</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Matthew Nunes</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/170211-nunesmatthew.pdf">Summary statistics selection for ABC inference in R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII_2-MolecCellBio_3-Nunes.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Maarten van Iterson</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/070311-user2011_vaniterson.pdf">Power and minimal sample size for multivariate analysis of microarrays</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII_2-MolecCellBio_4-vanIterson.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Mixed Effect Models, MS.03, Chair: Douglas Bates</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Ulrich Halekoh</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/290311-halekohulrich.pdf">Kenward-Roger modification of the F-statistic for some linear mixed models fitted with lmer</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII_3-MixedEffects_1-Halekoh.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Marco Geraci</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/280311-geracimarco.pdf">lqmm: Estimating Quantile Regression Models for Independent and Hierarchical Data with R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII-2-Geraci.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Kenneth Knoblauch</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/030411-knoblauchken.pdf">Mixed-effects Maximum Likelihood Difference Scaling</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII_3-MixedEffects_4-Knoblauch.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Programming, MS.01, Chair: Uwe Ligges</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Ray Brownrigg</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/140111-brownriggray.pdf">Tricks and Traps for Young Players</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII_4-Programming_1-Brownrigg.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Friedrich Schuster</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/300311-user2011_abstract_patterns_en.pdf">Software design patterns in R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII_4-Programming_2-Schuster.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Patrick Burns</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/300311-burnspatrick.pdf">Random input testing with R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII_4-Programming_2-Burns.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Data Mining Applications, MS.02, Chair: Przemys</strong><strong>aw Biecek</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Stephan Stahlschmidt</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-stahlschmidt_abstract.pdf">Predicting the offender&#8217;s age</a></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Daniel Chapsky</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/110311-chapskydaniel.pdf">Leveraging Online Social Network Data and External Data Sources to Predict Personality</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1115_FocusIII_5-DataMining_2-Chapsky.pdf">Slides</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>14:45 &#8211; 15:30</strong></p>
</td>
<td colspan="2"><strong>Invited Talk, MS.01/MS.02, Chair: John Aston</strong></td>
<td></td>
</tr>
<tr>
<td valign="top" width="88"></td>
<td valign="top" width="136">Brandon Whitcher</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/invited/user2011_Whitcher.pdf">Quantitative Medical Image Analysis</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Invited/Whitcher-Quantitative_Medical_Image_Analysis.pdf">Slides</a>] [<a href="http://www.r-bloggers.com/RUG/2011/10/user-2011-brandon-whitcher-quantitative-medical-image-analysis/">Video</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>16:00 &#8211; 17:00</strong></p>
</td>
<td colspan="2"><strong>Development of R, B3.02, Chair: John C. Nash</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Andrew R. Runnalls</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-runnallsandrew.pdf">Interpreter Internals: Unearthing Buried Treasure with CXXR</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1600_FocusIV_1-DevelOfR_2-Runnalls.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Geospatial Techniques, B3.03, Chair: Roger Bivand</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Binbin Lu</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/110311-transform_a_spatial_network_to_a_graph_in_r.pdf">Converting a spatial network to a graph in R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1600_FocusIV_2-Geospatial_1-Lu.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Rainer M Krug</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-krugrainerm.pdf">Spatial modelling with the R-GRASS Interface</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1600_FocusIV_2-Geospatial_2-Krug.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Daniel Nüst</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/210211-nuestdaniel.pdf">sos4R &#8211; Accessing SensorWeb Data from R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1600_FocusIV_2-Geospatial_3-Nust.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Genomics and Bioinformatics, MS.03, Chair: Ramón Diaz-Uriarte</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Sebastian Gibb</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/280311-gibbsebastian.pdf">MALDIquant: Quantitative Analysis of MALDI-TOF Proteomics Data</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1600_FocusIV_3-Genomics_1-Gibb.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Regression Modelling, MS.01, Chair: Cristiano Varin</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Bettina Grün</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/210311-zeileisgruencribari-neto.pdf">Beta Regression: Shaken, Stirred, Mixed, and Partitioned</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1600_FocusIV_4-Regression_1-Grun.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Rune Haubo B. Christensen</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-christensenrune.pdf">Regression Models for Ordinal Data: Introducing R-package ordinal</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1600_FocusIV_4-Regression_2-Haubo.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Giuseppe Bruno</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/280311-brunogiuseppe.pdf">Multiple choice models: why not the same answer? A comparison among LIMDEP, R, SAS and Stata</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1600_FocusIV_4-Regression_3-Bruno.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>R in the Business World, MS.02, Chair: David Smith</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Derek McCrae Norton</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-norton_user2011_abstract.pdf">Odysseus vs. Ajax: How to build an R presence in a corporate SAS environment</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1600_FocusIV_5-RinBusiness_1-Norton.pdf">Slides</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>17:05 &#8211; 18:05</strong></p>
</td>
<td colspan="2"><strong>Hydrology and Soil Science, B3.02, Chair: Thomas Petzoldt</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Wayne Jones</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/220311-jones_wayne.pdf">GWSDAT (GroundWater Spatiotemporal Data Analysis Tool)</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_1-Hydrology_1-Jones.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Pierre Roudier</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/040411-roudierpierre.pdf">Visualisation and modelling of soil data using the aqp package</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_1-Hydrology_3-Roudier.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Biostatistical Modelling, B3.03, Chair: Holger Hoefling</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Annamaria Guolo</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-guolo-varin.pdf">Higher-order likelihood inference in meta-analysis using R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_2-Biostat_2-Guolo.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Cristiano Varin</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-masarotto-varin.pdf">Gaussian copula regression using R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_2-Biostat_3-Varin.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Psychometrics, MS.03, Chair: Yves Rosseel</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Florian Wickelmaier</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/020411-wickelmaierflorian.pdf">Multinomial Processing Tree Models in R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_3-Psychometrics_1-Wickelmaier.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Basil Abou El-Komboz</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/290311-abstract_psychotree.pdf">Detecting Invariance in Psychometric Models with the psychotree Package</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_3-Psychometrics_2-ElKomboz.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Multivariate Data, MS.01, Chair: Peter Dalgaard</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">John Fox</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/220111-user2011_john-fox.pdf">Tests for Multivariate Linear Models with the car Package</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_4-Multivariate_1-Fox.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Julie Josse</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/140311-jossejulie.pdf">missMDA: a package to handle missing values in and with multivariate exploratory data analysis methods</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_4-Multivariate_2-Josse.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">António Pedro Duarte Silva</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-user2011_dsilva_brito.pdf">MAINT.DATA: Modeling and Analysing Interval Data in R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_4-Multivariate_3-Silva.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Interfaces, MS.02, Chair: Matthew Shotwell</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Xavier de Pedro Puente</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/030411-depedroxavier_sanchezalex.pdf">Web 2.0 for R scripts and workflows: Tiki and PluginR</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_5-Interfaces_1-dePedro.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="136">Sheri Gilley</td>
<td valign="top" width="302"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-user2011_gilley_a_new_gui_for_r.pdf">A new task-based GUI for R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/17Aug_1705_FocusV_5-Interfaces_3-Gilley.pdf">Slides</a>]</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Thursday 18th August</strong></p>
<div align="center">
<table border="1" cellpadding="0">
<tbody>
<tr>
<td>
<p align="center"><strong>09:00 &#8211; 09:45</strong></p>
</td>
<td colspan="2"><strong>Invited Talk, MS.01/MS.02, Chair: Julia Brettschneider</strong></td>
<td width="52"></td>
</tr>
<tr>
<td valign="top" width="76"></td>
<td valign="top" width="188">Wolfgang Huber</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/invited/user2011_Huber.pdf">Genomes and phenotypes</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Invited/Huber-Genomes_and_phenotypes.pdf">Slides</a>] [<a href="http://www.r-bloggers.com/RUG/2011/10/http%3A/www.r-bloggers.com/RUG/2011/10/user-2011-wolfgang-huber-genomes-and-phenotypes/">Video</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>09:50 &#8211; 10:50</strong></p>
</td>
<td colspan="2"><strong>Financial Models, B3.02, Chair: Giovanni Petris</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Peter Ruckdeschel</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/300311-ruckdeschelpeter.pdf">(Robust) Online Filtering in Regime Switching Models and Application to Investment Strategies for Asset Allocation</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_1-Finance_3-Ruckdeschel.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Ecology and Ecological Modelling, B3.03, Chair: Karline Soetaert</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Christian Kampichler</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-kampichlerchristian.pdf">Using R for the Analysis of Bird Demography on a Europe-wide Scale</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_2-Ecology_1-Kampichler.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">John C. Nash</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/140311-nashjohnc.pdf">An effort to improve nonlinear modeling practice</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_2-Ecology_3-Nash.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Generalized Linear Models, MS.03, Chair: Kenneth Knoblauch</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Ioannis Kosmidis</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/040411-kosmidisioannis.pdf">brglm: Bias reduction in generalized linear models</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_3-GLM-3-Kosmidis.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Merete K. Hansen</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-hansenmerete.pdf">The binomTools package: Performing model diagnostics on binomial regression models</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_3-GLM-3_Hansen.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Reporting Data, MS.01, Chair: Martyn Plummer</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Sina Rüeger</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/230311-rueegersina.pdf">uniPlot &#8211; A package to uniform and customize R graphics</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_4-ReportingData_1-Rueger.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Alexander Kowarik</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/110211-kowarikalexander.pdf">sparkTable: Generating Graphical Tables for Websites and Documents with R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_4-ReportingData_2-Kowarik.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Isaac Subirana</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-subiranaisaac.pdf">compareGroups package, updated and improved</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_4-ReportingData_3-Subirana.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Process Optimization, MS.02, Chair: Tobias Verbeke</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Emilio López</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/300311-lopezemilio.pdf">Six Sigma Quality Using R: Tools and Training</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_5-ProcessOptimization_1-Lopez.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Thomas Roth</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-roththomas2.pdf">Process Performance and Capability Statistics for Non-Normal Distributions in R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_0950_FocusVI_5-ProcessOptimization_2-Roth.pdf">Slides</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>11:15 &#8211; 12:35</strong></p>
</td>
<td colspan="2"><strong>Inference, B3.02, Chair: Peter Ruckdeschel</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Henry Deng</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/260111-denghenry.pdf">Density Estimation Packages in R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1115_FocusVII_1-Inference_1-Deng.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Population Genetics and Genetics Association Studies, B3.03, Chair: Martin Morgan</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Benjamin French</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/160311-frenchbenjamin.pdf">Simple haplotype analyses in R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1115_FocusVII_2-PopuGenetics_1-French.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Neuroscience, MS.03, Chair: Brandon Whitcher</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Karsten Tabelow</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-user2011_fmri.pdf">Statistical Parametric Maps for Functional MRI Experiments in R: The Package fmri</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1115_FocusVII_3-Neuroscience_2-Tabelow.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Data Management, MS.01, Chair: Barry Rowlingson</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Susan Ranney</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-ranneysusan.pdf">It&#8217;s a Boy! An Analysis of Tens of Millions of Birth Records Using R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1115_FocusVII_4-DataMgmt_1-Ranney.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Joanne Demmler</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/290311-demmlerjoanne.pdf">Challenges of working with a large database of routinely collected health data: Combining SQL and R</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1115_FocusVII_4-DataMgmt_2-Demmler.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Interactive Graphics in R, MS.02, Chair: Paul Murrell</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Richard Cotton</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/310311-cottonrichard.pdf">Easy Interactive ggplots</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1115_FocusVII_5-InteractiveGraphics_3-Cotton.pdf">Slides</a>]</td>
</tr>
<tr>
<td>
<p align="center"><strong>14:00 &#8211; 15:00</strong></p>
</td>
<td colspan="2"><strong>Kaleidoscope IIIa, MS.03, Chair: Adrian Bowman</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Thomas Petzoldt</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/010411-petzoldtthomas.pdf">Using R for systems understanding &#8211; a dynamic approach</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1400_KaleidIIIa_1-Petzoldt.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">David L. Miller</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/280311-millerdavid.pdf">Using multidimensional scaling with Duchon splines for reliable finite area smoothing</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1400_KaleidIIIa_2-Miller.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Alastair Sanderson</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/300311-sandersonalastair.pdf">Studying galaxies in the nearby Universe, using R and ggplot2</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1400_KaleidIIIa_3-Sanderson.pdf">Slides</a>]</td>
</tr>
<tr>
<td></td>
<td colspan="2"><strong>Kaleidoscope IIIb, MS.02, Chair: Frank Harrell</strong></td>
<td></td>
</tr>
<tr>
<td></td>
<td valign="top" width="188">Paul Murrell</td>
<td valign="top" width="261"><a href="http://www.warwick.ac.uk/statsdept/useR-2011/abstracts/060211-processing.pdf">Vector Image Processing</a></td>
<td valign="top" width="52">[<a href="http://www.warwick.ac.uk/statsdept/user-2011/TalkSlides/Contributed/18Aug_1400_KaleidIIIb_2-Murrell.pdf">Slides</a>]</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2011/12/user-2011-slides-and-videos-on-one-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 5.556 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-05-09 00:58:51 --><!-- Compression = gzip -->

